Subject: bug#32932: 27.0.50; render bugs on macOS Mojave

From: Alan Third <[email-masked]>
Date: Sun, 4 Nov 2018 20:11:48 +0000

On Sun, Nov 04, 2018 at 01:24:04PM +0000, Alan Third wrote:
> 
> I think what’s probably happening is that when the image begins to
> load the emacs window containing the dired buffer is marked as
> garbaged as it’s going to be replaced by the buffer containing the
> image, however because there’s a reasonably long gap between the user
> requesting the opening of the image, and the image actually loading
> redisplay and expose_frame have time to run.
> 
> Because the window is marked as garbaged expose_window doesn’t do
> anything.

After thinking about this for a while I realised that what we probably
need to do is just make sure the frame is updated before redisplay
starts changing it.

This seems to work here:

modified   src/nsterm.m
@@ -1061,6 +1061,17 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
 
   ns_update_auto_hide_menu_bar ();
 
+  /* Flush any existing changes to screen before redisplay gets going.
+     If we don't do this then it's possible for redisplay to mark
+     areas as garbaged so they won't be redrawn in the next drawRect
+     call.
+
+     Is this a bad thing to do since we're effectively calling
+     frame_expose from within redisplay?  */
+  block_input ();
+  [FRAME_NS_VIEW (f) displayIfNeeded];
+  unblock_input ();
+
   if ([view isFullscreen] && [view fsIsNative])
   {
     // Fix reappearing tool bar in fullscreen for Mac OS X 10.7

-- 
Alan Third