Subject: bug#72986: Disabling menu-bar-mode changes size of new frames

From: martin rudalics <[email-masked]>
Date: Thu, 7 Nov 2024 10:49:17 +0100

> Nov 05 22:31:36 dwks gnome-shell[3900]: GEOMETRY: Setting up constraint
 > info:
 >                                            orig: 0,0 1328x1308
 >                                            new : 0,0 400x456
 >                                            action_type     : Move&Resize
 >                                            is_user_action  : false
 >                                            resize_gravity  :
 > META_GRAVITY_NORTH_WEST
 >                                            fixed_directions: None
 >                                            work_area_monitor: 0,58 3840x2102
 >                                            entire_monitor   : 0,0 3840x2160

Again this only seems to confirm that the new size 400x456 is requested
somewhere _before_ mutter comes into play.

 > Mostly, the newlines in the message confuse the grep!

It might be easier to restrict journalctl output via the -S and -U
options, feed its output into Emacs and do the searching there.

Since, as you said earlier, you can't debug GTK (I have the same problem
here) and the only person who might have done that in the past has left
us long ago, I can only try a guess at where GTK (or maybe Emacs itself)
could mess up things.

One problem I see is that in emacsgtkfixed.c we set up the preferred
size of the frame widget and take the width and size from our
min_width/min_height size hints.  From the mutter log we know that these
are broken so maybe GTK does something weird with them.  Please put
breakpoints at the lines

   if (minimum) *minimum = w;

and

   if (minimum) *minimum = h;

within the #else parts of emacs_fixed_get_preferred_width and
emacs_fixed_get_preferred_height in emacsgtkfixed.c and tell me which
values are assigned here: Once for a good scenario and once for a bad
one.  Here I get 0 initially and later on 110 for h and 90 for w.

Experimentally, you could also try to use some arbitrary integer value
here so the code there becomes

#else
   int w = priv->f->output_data.x->size_hints.min_width;
   w = max (w, 800);
   if (minimum) *minimum = w;
   if (natural) *natural = w;
#endif

and

#else
   int h = priv->f->output_data.x->size_hints.min_height;
   h = max (h, 800);
   if (minimum) *minimum = h;
   if (natural) *natural = h;
#endif

and see whether your frame still shrinks.  Obviously, such a setting
will inhibit shrinking your frame later on but here we want to know
whether these functions are responsible for the weird behavior you see.

martin