emacs-devel
[Top][All Lists]
Advanced

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

Re: nsterm.m: How to prevent _inactive_ window update from overreaching.


From: Keith David Bershatsky
Subject: Re: nsterm.m: How to prevent _inactive_ window update from overreaching.
Date: Sun, 25 Nov 2018 18:14:19 -0800

I isolated the issue to the following changes within nsterm.m that were made 
between the dates of 07/07/2018 and 11/16/2018.  The additions (+) permit 
crosshairs to work properly; whereas, the subtractions (-) cause the issue 
outlined at the beginning of this thread.

The crosshairs code (in the attached patch from 11/16/2018) work correctly on 
all three GUI platforms:  NS, NT, X11.

Is it possible that something in the changes below is responsible for the 
issue, rather than the crosshairs code itself?

Keith

diff --git a/src/nsterm.m b/src/nsterm.m
index bcc23ff..eb7b72b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -278,6 +278,9 @@ - (NSColor *)colorUsingDefaultColorSpace
 long context_menu_value = 0;
 
 /* display update */
+static struct frame *ns_updating_frame;
+static NSView *focus_view = NULL;
+static BOOL gsaved = NO;
 static int ns_window_num = 0;
 static BOOL ns_fake_keydown = NO;
 #ifdef NS_IMPL_COCOA
@@ -1103,6 +1116,9 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool 
isFullscreen)
       [toolbar setVisible: tbar_visible];
   }
 
+  ns_updating_frame = f;
+  [view lockFocus];
+
   /* drawRect may have been called for say the minibuffer, and then clip path
      is for the minibuffer.  But the display engine may draw more because
      we have set the frame as garbaged.  So reset clip path to the whole
@@ -1206,12 +1222,21 @@ static NSRect constrain_frame_rect(NSRect frameRect, 
bool isFullscreen)
    external (RIF) call; for whole frame, called after update_window_end
    -------------------------------------------------------------------------- 
*/
 {
+  EmacsView *view = FRAME_NS_VIEW (f);
+
   NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end");
 
 /*   if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
   MOUSE_HL_INFO (f)->mouse_face_defer = 0;
-}
 
+  block_input ();
+
+  [view unlockFocus];
+  [[view window] flushWindow];
+
+  unblock_input ();
+  ns_updating_frame = NULL;
+}
 
 static BOOL
 ns_clip_to_rect (struct frame *f, NSRect *r, int n)
@@ -1226,23 +1261,31 @@ static NSRect constrain_frame_rect(NSRect frameRect, 
bool isFullscreen)
     {
       NSTRACE_RECT ("r", *r);
 
-      if ([NSView focusView] == FRAME_NS_VIEW (f))
-        {
-          [[NSGraphicsContext currentContext] saveGraphicsState];
-          if (n == 2)
-            NSRectClipList (r, 2);
-          else
-            NSRectClip (*r);
-
-          return YES;
-        }
-      else
+      if (f != ns_updating_frame)
         {
           NSView *view = FRAME_NS_VIEW (f);
-          int i;
-          for (i = 0 ; i < n ; i++)
-            [view setNeedsDisplayInRect:r[i]];
+          if (view != focus_view)
+            {
+              if (focus_view != NULL)
+                {
+                  [focus_view unlockFocus];
+                  [[focus_view window] flushWindow];
+              /* debug_lock--; */
+              return YES;
+                }
+              if (view)
+                [view lockFocus];
+              focus_view = view;
+              /* if (view) debug_lock++; */
+            }
         }
+      [[NSGraphicsContext currentContext] saveGraphicsState];
+      if (n == 2)
+        NSRectClipList (r, 2);
+      else
+        NSRectClip (*r);
+      gsaved = YES;
+      return YES;
     }
 
   return NO;
@@ -1256,7 +1299,22 @@ static NSRect constrain_frame_rect(NSRect frameRect, 
bool isFullscreen)
 {
   NSTRACE_WHEN (NSTRACE_GROUP_FOCUS, "ns_reset_clipping");
 
-  [[NSGraphicsContext currentContext] restoreGraphicsState];
+  if (gsaved)
+    {
+      [[NSGraphicsContext currentContext] restoreGraphicsState];
+      gsaved = NO;
+    }
+
+  if (f != ns_updating_frame)
+    {
+      if (focus_view != NULL)
+        {
+          [focus_view unlockFocus];
+          [[focus_view window] flushWindow];
+          focus_view = NULL;
+/* debug_lock--; */
+        }
+    }
 }
 
 

Attachment: 644a308b4e1513e04be9360e1586e14b32ec0159__2018_11_16.diff
Description: application/diff


reply via email to

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