Subject: Re: bug#38181: Actual height of mode-line not taken into account

From: Eli Zaretskii <[email-masked]>
Date: Sun, 17 Nov 2019 19:22:54 +0200

> Cc: [email-masked], [email-masked]
> From: martin rudalics <[email-masked]>
> Date: Sun, 17 Nov 2019 10:01:44 +0100
> 
>  > Maybe fit-window-to-buffer should set some hook, which redisplay
>  > should call if it finds out that the mode-line height changed?
> 
> Maybe a two-bits sticky bit-field in the window structure called
> refit_window_to_buffer.  The Lisp interface to it is a function called
> 'refit-window-to-buffer' setting refit_window_to_buffer to 1 if it is
> zero.  'fit-window-to-buffer' always calls 'refit-window-to-buffer'.

I'd prefer a hook, because the problem probably isn't limited to
fit-window-to-buffer.

Wait, don't we already call window-size-change-functions in this case?
If not, would it help if we did?

> display_mode_lines sets refit_window_to_buffer to 2 provided it is 1
> and the mode line height of this window has changed.

The detection of the change in mode-line height is outside
display_mode_lines, see the snippet I posted up-thread.

> The display engine eventually calls 'fit-window-to-buffer' for all
> windows that have refit_window_to_buffer equal 2 and sets it to 3.

We need to figure out the "eventually" part.  It should happen after
the windows have their dimensions updated due to the mode-line
changes.  Do you know where this happens?

> This might be tricky for windows stored in configurations and states.

Why tricky?  A stored configuration shouldn't be affected by any
changes after it's tored, no?

> And always remember the fact that in one and the same display cycle
> 'fit-window-to-buffer' may have been called for two windows above each
> other.

Mmm... actually, it could be that we cannot resize windows during
redisplay at all.  See, for example, how resize_mini_window does its
tricky job.  We may need to call this outside of redisplay.