unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: martin rudalics <rudalics@gmx.at>
Cc: pankaj@codeisgreat.org, 48162@debbugs.gnu.org
Subject: bug#48162: 28.0.50; Resizing using set-frame-width doesn't expand mode-line
Date: Sun, 2 May 2021 22:49:40 +0100	[thread overview]
Message-ID: <YI8edD1dI6863Q4X@idiocy.org> (raw)
In-Reply-To: <ee098a00-737d-8678-2835-fe88f0824340@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]

On Sun, May 02, 2021 at 09:19:20PM +0200, martin rudalics wrote:
> > Perhaps it just needs to look like this?
> >
> >    if ((oldh == newh && oldw == neww)
> >        || (newh == emacsframe->new_height
> >            && neww == emacsframe->new_width))
> >
> > This is hard, because I can't replicate either of the reported bugs
> > and I suspect my reasoning is very off here.
> 
> I think I understand now: When Emacs is busy it cannot set oldh and oldw
> immediately so oldh == newh && oldw == neww will continue to fail and we
> cannot return.  How about something like the below?

I think the attached works. I finally managed to reproduce the bug and
realised that the offscreen buffer's size doesn't really have anything
to do with what Emacs thinks the frame size is, so I've separated its
resizing code out.

Your suggested code for dealing with the Emacs frame size appears to
work right without any crashes on GNUstep too, so I've included it.

Now I just need to work out why using the menus causes GNUstep builds
to crash and we might have a semi-usable port again. ;)
-- 
Alan Third

[-- Attachment #2: 0001-Fix-incorrect-resizing-behaviour-on-macOS-bug-48157-.patch --]
[-- Type: text/x-diff, Size: 2365 bytes --]

From c4048b3cd6841a7f2ccdfb3f6c880c9ee176390a Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Sun, 2 May 2021 22:38:13 +0100
Subject: [PATCH] Fix incorrect resizing behaviour on macOS (bug#48157,
 bug#48162)

* 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 | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index 6e7ab1266b..bb20886ab1 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7303,16 +7303,34 @@ - (void)viewDidResize:(NSNotification *)notification
 
   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 @@ - (void)viewDidResize:(NSNotification *)notification
   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);
-- 
2.30.2


  reply	other threads:[~2021-05-02 21:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-02 15:42 bug#48162: 28.0.50; Resizing using set-frame-width doesn't expand mode-line Pankaj Jangid
2021-05-02 16:12 ` martin rudalics
2021-05-02 16:45   ` Alan Third
2021-05-02 16:57     ` martin rudalics
2021-05-02 17:18       ` Alan Third
2021-05-02 19:19         ` martin rudalics
2021-05-02 21:49           ` Alan Third [this message]
2021-05-03  3:40             ` Pankaj Jangid
2021-05-03 12:50               ` Alan Third
2021-05-03  7:49             ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YI8edD1dI6863Q4X@idiocy.org \
    --to=alan@idiocy.org \
    --cc=48162@debbugs.gnu.org \
    --cc=pankaj@codeisgreat.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).