Subject: bug#48162: 28.0.50; Resizing using set-frame-width doesn't expand mode-line

From: martin rudalics <[email-masked]>
Date: Sun, 2 May 2021 21:19:20 +0200

> I'm not sure. I was hoping you were going to tell me where I'm going
 > wrong! :)
 >
 > The only thing I can see is that in order to go into the block and
 > return when new_size_p is false requires newh == oldh == new_height.
 > And the same with width.
 >
 > Should it be this?
 >
 >    if ((oldh == newh && oldw == neww && !emacsframe->new_size_p)
 >        || (newh == emacsframe->new_height
 >            && neww == emacsframe->new_width))
 >
 > But I'm still not sure. If we have a change pending and the WM sends
 > another change through, should we call change_frame_size with the new
 > sizes?

We should.

 > 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?

martin

--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7309,10 +7309,10 @@ - (void)viewDidResize:(NSNotification *)notification
    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;