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

From: martin rudalics <[email-masked]>
Date: Mon, 10 May 2021 10:23:26 +0200

>>> But maybe sometimes the value of tab-bar-lines
 >>> becomes more than 1?
 >>
 >> It's 2 after the tab bar has been produced for the first time by the
 >> display code.  And that is what's been causing trouble for you.  The
 >> value was oscillating between 1 and 2.
 >
 > Very strange indeed, I can't find the constant 2 in the source code.

Because for X it's done in x_change_tab_bar_height as (I suppose you
wrote that):

x_change_tab_bar_height (struct frame *f, int height)
{
   int unit = FRAME_LINE_HEIGHT (f);
   int old_height = FRAME_TAB_BAR_HEIGHT (f);
   int lines = (height + unit - 1) / unit;
   Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);

   /* Make sure we redisplay all windows in this frame.  */
   fset_redisplay (f);

   /* Recalculate tab bar and frame text sizes.  */
   FRAME_TAB_BAR_HEIGHT (f) = height;
   FRAME_TAB_BAR_LINES (f) = lines;
   store_frame_param (f, Qtab_bar_lines, make_fixnum (lines));

If you call this with a HEIGHT that is larger than FRAME_LINE_HEIGHT you
already get a `tab-bar-lines' parameter that is larger than 1.  With a
very small FRAME_LINE_HEIGHT and/or a very tall tab bar you may get more
than 2 lines.

This is an idiosyncrasy of our "live in a graphic world but think in
terms of a TTY" philosophy.  The parameter should be a boolean and have
been called something like 'tab_bar_p' but there's no chance to change
that any more.

martin