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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 15 Nov 2019 21:38:27 +0200

> Date: Fri, 15 Nov 2019 15:48:53 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > From: Jonas Bernoulli <[email-masked]>
> > Date: Tue, 12 Nov 2019 17:52:59 +0100
> > 
> > If the height of the mode-line is increased by inserting an image into
> > it, then that height is not taken into account in a buffer/window until
> > `redisplay' has been called at least once since the buffer was created.
> 
> AFAIR, the mode line display is done lazily, because otherwise the
> mode line would flicker.  When you change the face, that triggers a
> thorough redisplay, because any change in faces does that (it could
> mean many faces now have a different appearance).  Adding an image to
> the mode line doesn't have that effect, which is why you need to force
> redisplay manually.

Btw, I was wrong above: enlarging the mode-line faces also causes a
similar problem.  Try this slightly modified recipe:

  (defun test-popup ()
    (interactive)
    (set-face-attribute 'mode-line nil :height 350)
    (set-face-attribute 'mode-line-inactive nil :height 350)
    (with-current-buffer (generate-new-buffer "*test*")
      (save-excursion
	(insert "one\ntwo\nthree\nfour\nfive"))
      (let ((win (display-buffer (current-buffer)
				 '(display-buffer-in-side-window
				   (side . bottom)))))
	(fit-window-to-buffer win))))

and you will see that the buffer *test* isn't shown in its entirety,
either.

I think fit-window-to-buffer relies on window's metrics (like the
number of lines in the text area) to be up to date, and that is only
true after a window was redisplayed once since changing the mode-line
height.  Martin, is this correct?