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

From: Alan Third <[email-masked]>
Date: Sun, 2 May 2021 18:18:05 +0100

On Sun, May 02, 2021 at 06:57:08PM +0200, martin rudalics wrote:
> > This patch reintroduces the infinite loop I was trying to avoid.
> >
> > viewDidResize is called every time the view's "frame" is touched. Most
> > of the time this happens when nothing has changed, but calling
> > change_frame_size, even when nothing has changed, appears to cause the
> > toolbar to redraw, which causes viewDidResize to be called again, and
> > so on ad infinitum.
> >
> > So I put in the check whether the new frame size that's reported is
> > actually the same as the previous frame size, and if so do nothing.
> > Then realised that I need to check the new_height and new_width
> > settings in case the change is already pending.
> >
> > I'm not sure where new_size_p comes into it, perhaps we don't even
> > need to check it in viewDidResize, because all we care about is the
> > final outcome?
> >
> > Maybe this really isn't the way to do it and I need to keep track of
> > the frame size separately, which is something I was hoping to avoid.
> 
> new_size_p true means that Emacs has already received a resize event for
> this frame but was not yet able to process it.  So the additional
> 
>           || (newh == emacsframe->new_height
> 	      && neww == emacsframe->new_width)))
> 
> in that case should "do nothing" when "nothing has changed".  Where does
> my reasoning go wrong?

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?

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.
-- 
Alan Third