Subject: Re: bug#46827: Broken initial size of GTK3 frame

From: martin rudalics <[email-masked]>
Date: Mon, 1 Mar 2021 09:32:10 +0100

> This is very strange, that commit was not supposed to affect frame
 > dimensions.
 >
 > Could you please step through the relevant frame-sizing code, and see
 > how that zero_vector entry in the font-cache causes this problem?

The bug seems to be caused by the part of the tool bar code that tries
to detect the height of the tool bar and resize the frame
correspondingly.  Turning off the tool bar makes the bug disappear.

The font.c change garbles the order of the calls of frame resizing
routines.  The following lines produced by `frame--size-history' are
from a "good" run (with the patch I posted earlier here applied)

FRAME-NOTICE-USER	 nil ((cursor-color . red3) (width . 80) (height . 32))
adjust-frame-size-1	 (720 648 720 576) (x-set-frame-parameters 1)
adjust-frame-size-2	 (720 648 720 576) (nil nil)
xg-frame-set-char-size-3 (720 648 720 576) (752 601)
xg-frame-resized	 (720 648 720 576) nil

adjust-frame-size-1	 (720 648 720 576) (change-frame-size 5)
adjust-frame-size-3	 (720 648 720 576) (752 648 752 576)

update-frame-tool-bar	 nil nil
adjust-frame-size-1	 (720 576 720 576) (tool-bar-lines 2)
adjust-frame-size-2	 (720 576 720 576) (nil nil)
xg-frame-set-char-size-3 (720 576 720 576) (752 642)
xg-frame-resized	 (720 576 720 576) nil

while these lines are from a "bad" run (one showing the bug)

FRAME-NOTICE-USER	 nil ((cursor-color . red3) (width . 80) (height . 32))
adjust-frame-size-1	 (720 648 720 576) (x-set-frame-parameters 1)
adjust-frame-size-2	 (720 648 720 576) (nil nil)
xg-frame-set-char-size-3 (720 648 720 576) (752 601)
xg-frame-resized	 (720 648 720 576) nil

update-frame-tool-bar	 nil nil
adjust-frame-size-1	 (720 648 720 648) (tool-bar-lines 2)
adjust-frame-size-2	 (720 648 720 648) (nil nil)
xg-frame-set-char-size-3 (720 648 720 648) (752 714)
xg-frame-resized	 (720 648 720 648) nil

adjust-frame-size-1	 (720 648 720 576) (change-frame-size 5)
adjust-frame-size-3	 (720 648 720 576) (752 648 752 576)

In the bad run, the `change-frame-size' call apparently gets delayed (by
a skipped 'do_pending_window_change' presumably) until after an
update_frame_tool_bar call gets there first.  But so far I have no idea
why font cache issues would have any impact on the order of how things
get executed here.

martin