diff options
| author | Alan Third | 2020-03-02 17:44:38 +0000 |
|---|---|---|
| committer | Alan Third | 2020-03-02 18:29:09 +0000 |
| commit | 68109c56e45ff531934bfe81f9bd14a530a35574 (patch) | |
| tree | d488b135e92a24b19f1557cd19d3c3e38074c3e4 /src | |
| parent | 1939f7580bd283286dce8be7c99ab5dec1bb0814 (diff) | |
| download | emacs-68109c56e45ff531934bfe81f9bd14a530a35574.tar.gz emacs-68109c56e45ff531934bfe81f9bd14a530a35574.zip | |
Fix #defines controlling when NS port draws to offscreen buffer
* src/nsterm.h (NS_DRAW_TO_BUFFER): New definition.
* src/nsterm.m (ns_update_begin):
(ns_update_end):
(ns_focus):
([EmacsView updateFrameSize:]):
([EmacsView initFrameFromEmacs:]):
([EmacsView copyRect:to:]): Use new #define.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.h | 22 | ||||
| -rw-r--r-- | src/nsterm.m | 20 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/nsterm.h b/src/nsterm.h index 7c6197f1288..db966e1581b 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -339,6 +339,22 @@ typedef id instancetype; | |||
| 339 | #endif | 339 | #endif |
| 340 | 340 | ||
| 341 | 341 | ||
| 342 | /* macOS 10.14 and above cannot draw directly "to the glass" and | ||
| 343 | therefore we draw to an offscreen buffer and swap it in when the | ||
| 344 | toolkit wants to draw the frame. GNUstep and macOS 10.7 and below | ||
| 345 | do not support this method, so we revert to drawing directly to the | ||
| 346 | glass. | ||
| 347 | |||
| 348 | FIXME: Should we make this macOS 10.8+, or macOS 10.14+? I'm | ||
| 349 | inclined to go with 10.14+ as there have been some reports of funny | ||
| 350 | behaviour on 10.13 and below. It may be worth adding a variable to | ||
| 351 | allow people in the overlapping region to switch between drawing | ||
| 352 | paths. */ | ||
| 353 | #if defined (NS_IMPL_COCOA) && defined (MAC_OS_X_VERSION_10_14) | ||
| 354 | #define NS_DRAW_TO_BUFFER 1 | ||
| 355 | #endif | ||
| 356 | |||
| 357 | |||
| 342 | /* ========================================================================== | 358 | /* ========================================================================== |
| 343 | 359 | ||
| 344 | NSColor, EmacsColor category. | 360 | NSColor, EmacsColor category. |
| @@ -417,7 +433,7 @@ typedef id instancetype; | |||
| 417 | int maximized_width, maximized_height; | 433 | int maximized_width, maximized_height; |
| 418 | NSWindow *nonfs_window; | 434 | NSWindow *nonfs_window; |
| 419 | BOOL fs_is_native; | 435 | BOOL fs_is_native; |
| 420 | #ifdef NS_IMPL_COCOA | 436 | #ifdef NS_DRAW_TO_BUFFER |
| 421 | CGContextRef drawingBuffer; | 437 | CGContextRef drawingBuffer; |
| 422 | #endif | 438 | #endif |
| 423 | @public | 439 | @public |
| @@ -460,11 +476,11 @@ typedef id instancetype; | |||
| 460 | #endif | 476 | #endif |
| 461 | - (int)fullscreenState; | 477 | - (int)fullscreenState; |
| 462 | 478 | ||
| 463 | #ifdef NS_IMPL_COCOA | 479 | #ifdef NS_DRAW_TO_BUFFER |
| 464 | - (void)focusOnDrawingBuffer; | 480 | - (void)focusOnDrawingBuffer; |
| 481 | - (void)createDrawingBuffer; | ||
| 465 | #endif | 482 | #endif |
| 466 | - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect; | 483 | - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect; |
| 467 | - (void)createDrawingBuffer; | ||
| 468 | 484 | ||
| 469 | /* Non-notification versions of NSView methods. Used for direct calls. */ | 485 | /* Non-notification versions of NSView methods. Used for direct calls. */ |
| 470 | - (void)windowWillEnterFullScreen; | 486 | - (void)windowWillEnterFullScreen; |
diff --git a/src/nsterm.m b/src/nsterm.m index 84acb61dcd1..57bb9b1dd83 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1117,7 +1117,7 @@ ns_update_begin (struct frame *f) | |||
| 1117 | #endif | 1117 | #endif |
| 1118 | 1118 | ||
| 1119 | ns_updating_frame = f; | 1119 | ns_updating_frame = f; |
| 1120 | #ifdef NS_IMPL_COCOA | 1120 | #ifdef NS_DRAW_TO_BUFFER |
| 1121 | [view focusOnDrawingBuffer]; | 1121 | [view focusOnDrawingBuffer]; |
| 1122 | #else | 1122 | #else |
| 1123 | [view lockFocus]; | 1123 | [view lockFocus]; |
| @@ -1139,7 +1139,7 @@ ns_update_end (struct frame *f) | |||
| 1139 | /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ | 1139 | /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ |
| 1140 | MOUSE_HL_INFO (f)->mouse_face_defer = 0; | 1140 | MOUSE_HL_INFO (f)->mouse_face_defer = 0; |
| 1141 | 1141 | ||
| 1142 | #ifdef NS_IMPL_COCOA | 1142 | #ifdef NS_DRAW_TO_BUFFER |
| 1143 | [NSGraphicsContext setCurrentContext:nil]; | 1143 | [NSGraphicsContext setCurrentContext:nil]; |
| 1144 | #else | 1144 | #else |
| 1145 | block_input (); | 1145 | block_input (); |
| @@ -1172,7 +1172,7 @@ ns_focus (struct frame *f, NSRect *r, int n) | |||
| 1172 | } | 1172 | } |
| 1173 | 1173 | ||
| 1174 | if (f != ns_updating_frame) | 1174 | if (f != ns_updating_frame) |
| 1175 | #ifdef NS_IMPL_COCOA | 1175 | #ifdef NS_DRAW_TO_BUFFER |
| 1176 | [view focusOnDrawingBuffer]; | 1176 | [view focusOnDrawingBuffer]; |
| 1177 | #else | 1177 | #else |
| 1178 | { | 1178 | { |
| @@ -7091,8 +7091,10 @@ not_in_argv (NSString *arg) | |||
| 7091 | from non-native fullscreen, in other circumstances it appears | 7091 | from non-native fullscreen, in other circumstances it appears |
| 7092 | to be a noop. (bug#28872) */ | 7092 | to be a noop. (bug#28872) */ |
| 7093 | wr = NSMakeRect (0, 0, neww, newh); | 7093 | wr = NSMakeRect (0, 0, neww, newh); |
| 7094 | [self createDrawingBuffer]; | ||
| 7095 | [view setFrame: wr]; | 7094 | [view setFrame: wr]; |
| 7095 | #ifdef NS_DRAW_TO_BUFFER | ||
| 7096 | [self createDrawingBuffer]; | ||
| 7097 | #endif | ||
| 7096 | 7098 | ||
| 7097 | // To do: consider using [NSNotificationCenter postNotificationName:]. | 7099 | // To do: consider using [NSNotificationCenter postNotificationName:]. |
| 7098 | [self windowDidMove: // Update top/left. | 7100 | [self windowDidMove: // Update top/left. |
| @@ -7430,7 +7432,9 @@ not_in_argv (NSString *arg) | |||
| 7430 | maximizing_resize = NO; | 7432 | maximizing_resize = NO; |
| 7431 | #endif | 7433 | #endif |
| 7432 | 7434 | ||
| 7435 | #ifdef NS_DRAW_TO_BUFFER | ||
| 7433 | [self createDrawingBuffer]; | 7436 | [self createDrawingBuffer]; |
| 7437 | #endif | ||
| 7434 | 7438 | ||
| 7435 | win = [[EmacsWindow alloc] | 7439 | win = [[EmacsWindow alloc] |
| 7436 | initWithContentRect: r | 7440 | initWithContentRect: r |
| @@ -8210,7 +8214,7 @@ not_in_argv (NSString *arg) | |||
| 8210 | } | 8214 | } |
| 8211 | 8215 | ||
| 8212 | 8216 | ||
| 8213 | #ifdef NS_IMPL_COCOA | 8217 | #ifdef NS_DRAW_TO_BUFFER |
| 8214 | - (void)createDrawingBuffer | 8218 | - (void)createDrawingBuffer |
| 8215 | /* Create and store a new CGGraphicsContext for Emacs to draw into. | 8219 | /* Create and store a new CGGraphicsContext for Emacs to draw into. |
| 8216 | 8220 | ||
| @@ -8268,7 +8272,7 @@ not_in_argv (NSString *arg) | |||
| 8268 | expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame)); | 8272 | expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame)); |
| 8269 | } | 8273 | } |
| 8270 | } | 8274 | } |
| 8271 | #endif /* NS_IMPL_COCOA */ | 8275 | #endif /* NS_DRAW_TO_BUFFER */ |
| 8272 | 8276 | ||
| 8273 | 8277 | ||
| 8274 | - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect | 8278 | - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect |
| @@ -8277,7 +8281,7 @@ not_in_argv (NSString *arg) | |||
| 8277 | NSTRACE_RECT ("Source", srcRect); | 8281 | NSTRACE_RECT ("Source", srcRect); |
| 8278 | NSTRACE_RECT ("Destination", dstRect); | 8282 | NSTRACE_RECT ("Destination", dstRect); |
| 8279 | 8283 | ||
| 8280 | #ifdef NS_IMPL_COCOA | 8284 | #ifdef NS_DRAW_TO_BUFFER |
| 8281 | CGImageRef copy; | 8285 | CGImageRef copy; |
| 8282 | NSRect frame = [self frame]; | 8286 | NSRect frame = [self frame]; |
| 8283 | NSAffineTransform *setOrigin = [NSAffineTransform transform]; | 8287 | NSAffineTransform *setOrigin = [NSAffineTransform transform]; |
| @@ -8317,7 +8321,7 @@ not_in_argv (NSString *arg) | |||
| 8317 | } | 8321 | } |
| 8318 | 8322 | ||
| 8319 | 8323 | ||
| 8320 | #ifdef NS_IMPL_COCOA | 8324 | #ifdef NS_DRAW_TO_BUFFER |
| 8321 | - (BOOL)wantsUpdateLayer | 8325 | - (BOOL)wantsUpdateLayer |
| 8322 | { | 8326 | { |
| 8323 | return YES; | 8327 | return YES; |