emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 68109c5 1/2: Fix #defines controlling when NS port draws to offsc


From: Alan Third
Subject: master 68109c5 1/2: Fix #defines controlling when NS port draws to offscreen buffer
Date: Mon, 2 Mar 2020 13:31:23 -0500 (EST)

branch: master
commit 68109c56e45ff531934bfe81f9bd14a530a35574
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    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.
---
 src/nsterm.h | 22 +++++++++++++++++++---
 src/nsterm.m | 20 ++++++++++++--------
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/nsterm.h b/src/nsterm.h
index 7c6197f..db966e1 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 84acb61..57bb9b1 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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]