diff options
author | Alan Third <alan@idiocy.org> | 2020-03-02 17:44:38 +0000 |
---|---|---|
committer | Alan Third <alan@idiocy.org> | 2020-03-02 18:29:09 +0000 |
commit | 68109c56e45ff531934bfe81f9bd14a530a35574 (patch) | |
tree | d488b135e92a24b19f1557cd19d3c3e38074c3e4 /src | |
parent | 1939f7580bd283286dce8be7c99ab5dec1bb0814 (diff) | |
download | emacs-68109c56e45ff531934bfe81f9bd14a530a35574.tar.gz |
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; #endif +/* macOS 10.14 and above cannot draw directly "to the glass" and + therefore we draw to an offscreen buffer and swap it in when the + toolkit wants to draw the frame. GNUstep and macOS 10.7 and below + do not support this method, so we revert to drawing directly to the + glass. + + FIXME: Should we make this macOS 10.8+, or macOS 10.14+? I'm + inclined to go with 10.14+ as there have been some reports of funny + behaviour on 10.13 and below. It may be worth adding a variable to + allow people in the overlapping region to switch between drawing + paths. */ +#if defined (NS_IMPL_COCOA) && defined (MAC_OS_X_VERSION_10_14) +#define NS_DRAW_TO_BUFFER 1 +#endif + + /* ========================================================================== NSColor, EmacsColor category. @@ -417,7 +433,7 @@ typedef id instancetype; int maximized_width, maximized_height; NSWindow *nonfs_window; BOOL fs_is_native; -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER CGContextRef drawingBuffer; #endif @public @@ -460,11 +476,11 @@ typedef id instancetype; #endif - (int)fullscreenState; -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER - (void)focusOnDrawingBuffer; +- (void)createDrawingBuffer; #endif - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect; -- (void)createDrawingBuffer; /* Non-notification versions of NSView methods. Used for direct calls. */ - (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) #endif ns_updating_frame = f; -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER [view focusOnDrawingBuffer]; #else [view lockFocus]; @@ -1139,7 +1139,7 @@ ns_update_end (struct frame *f) /* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */ MOUSE_HL_INFO (f)->mouse_face_defer = 0; -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER [NSGraphicsContext setCurrentContext:nil]; #else block_input (); @@ -1172,7 +1172,7 @@ ns_focus (struct frame *f, NSRect *r, int n) } if (f != ns_updating_frame) -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER [view focusOnDrawingBuffer]; #else { @@ -7091,8 +7091,10 @@ not_in_argv (NSString *arg) from non-native fullscreen, in other circumstances it appears to be a noop. (bug#28872) */ wr = NSMakeRect (0, 0, neww, newh); - [self createDrawingBuffer]; [view setFrame: wr]; +#ifdef NS_DRAW_TO_BUFFER + [self createDrawingBuffer]; +#endif // To do: consider using [NSNotificationCenter postNotificationName:]. [self windowDidMove: // Update top/left. @@ -7430,7 +7432,9 @@ not_in_argv (NSString *arg) maximizing_resize = NO; #endif +#ifdef NS_DRAW_TO_BUFFER [self createDrawingBuffer]; +#endif win = [[EmacsWindow alloc] initWithContentRect: r @@ -8210,7 +8214,7 @@ not_in_argv (NSString *arg) } -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER - (void)createDrawingBuffer /* Create and store a new CGGraphicsContext for Emacs to draw into. @@ -8268,7 +8272,7 @@ not_in_argv (NSString *arg) expose_frame (emacsframe, 0, 0, NSWidth (frame), NSHeight (frame)); } } -#endif /* NS_IMPL_COCOA */ +#endif /* NS_DRAW_TO_BUFFER */ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect @@ -8277,7 +8281,7 @@ not_in_argv (NSString *arg) NSTRACE_RECT ("Source", srcRect); NSTRACE_RECT ("Destination", dstRect); -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER CGImageRef copy; NSRect frame = [self frame]; NSAffineTransform *setOrigin = [NSAffineTransform transform]; @@ -8317,7 +8321,7 @@ not_in_argv (NSString *arg) } -#ifdef NS_IMPL_COCOA +#ifdef NS_DRAW_TO_BUFFER - (BOOL)wantsUpdateLayer { return YES; |