]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix incorrect resizing behaviour on macOS (bug#48157, bug#48162)
authorAlan Third <alan@idiocy.org>
Sun, 2 May 2021 21:38:13 +0000 (22:38 +0100)
committerAlan Third <alan@idiocy.org>
Mon, 3 May 2021 12:51:55 +0000 (13:51 +0100)
* src/nsterm.m ([EmacsView viewDidResize:]): The drawing buffer can be
resized independently of Emacs's idea of the frame size.

Co-authored-by: martin rudalics <rudalics@gmx.at>
src/nsterm.m

index 6e7ab1266ba43cb9bef71d33d46aad029a7510eb..bb20886ab1d1b762e990c53cab78c9bb9b1c2941 100644 (file)
@@ -7303,16 +7303,34 @@ not_in_argv (NSString *arg)
 
   NSTRACE ("[EmacsView viewDidResize]");
 
+#ifdef NS_DRAW_TO_BUFFER
+  /* If the buffer size doesn't match the view's backing size, destroy
+     the buffer and let it be recreated at the correct size later.  */
+  if ([self wantsUpdateLayer] && surface)
+    {
+      NSRect surfaceRect = {{0, 0}, [surface getSize]};
+      NSRect frameRect = [[self window] convertRectToBacking:frame];
+
+      if (!NSEqualRects (frameRect, surfaceRect))
+        {
+          [surface release];
+          surface = nil;
+
+          [self setNeedsDisplay:YES];
+        }
+    }
+#endif
+
   neww = (int)NSWidth (frame);
   newh = (int)NSHeight (frame);
   oldw = FRAME_PIXEL_WIDTH (emacsframe);
   oldh = FRAME_PIXEL_HEIGHT (emacsframe);
 
   /* Don't want to do anything when the view size hasn't changed. */
-  if ((oldh == newh && oldw == neww)
-      || (emacsframe->new_size_p
-          && newh == emacsframe->new_height
-          && neww == emacsframe->new_width))
+  if (emacsframe->new_size_p
+      ? (newh == emacsframe->new_height
+         && neww == emacsframe->new_width)
+      : (oldh == newh && oldw == neww))
     {
       NSTRACE_MSG ("No change");
       return;
@@ -7321,16 +7339,6 @@ not_in_argv (NSString *arg)
   NSTRACE_SIZE ("New size", NSMakeSize (neww, newh));
   NSTRACE_SIZE ("Original size", NSMakeSize (oldw, oldh));
 
-#ifdef NS_DRAW_TO_BUFFER
-  if ([self wantsUpdateLayer])
-    {
-      [surface release];
-      surface = nil;
-
-      [self setNeedsDisplay:YES];
-    }
-#endif
-
   change_frame_size (emacsframe, neww, newh, false, YES, false);
 
   SET_FRAME_GARBAGED (emacsframe);