Subject: Re: bug#22000: 25.0.50; Running dired changes frame width, gtk_distribute_natural_allocation throws assertion

From: martin rudalics <[email-masked]>
Date: Wed, 25 Nov 2015 18:48:57 +0100

>> And obviously this is Bug#15700 ;-)
 >
 > I really need to improve my search-fu...

I could have noticed sooner too.  Google also lists:

https://bugzilla.redhat.com/show_bug.cgi?id=881760

https://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00276.html

https://bbs.archlinux.org/viewtopic.php?id=168847

https://cygwin.com/ml/cygwin/2013-07/msg00070.html

 >> I don't think we can/should do anything about this.
 >
 > Not sure about the "can", but I think we definitely should. The
 > dired-thing is already pretty annoying for people like my co-worker who
 > are very adamant about having an Emacs frame that is *exactly* 80
 > characters wide. He has to resize the frame every time he leaves Dired.
 >
 > Also, after some more testing, it seems pretty clear that the frame size
 > is battled out between GTK and Emacs when you make the width smaller
 > than the menu-bar. If you resize with the mouse, it depends on the
 > window manager what exactly happens, but I've seen two things:
 >
 > - with 'wmii', the window simply snaps back to the width that's needed
 >    by the menu bar
 >
 > - with 'i3', I can resize to a smaller width with the mouse, but during
 >    the resize I see flickering to the menu-bar width
 >
 > Also, it seems to be impossible to programatically set a frame width
 > that is smaller than the menu-bar. `set-frame-width' doesn't work,
 > neither does `initial-frame-alist' or even the '-geometry' switch.

Here with xfce ‘set-frame-width’ and ‘default-frame-alist’ both crop the
menubar.

 > Unfortunately, I'm not very familiar with GTK. My guess is that you
 > would somehow have to catch the 'size-allocate' signal and do The Right
 > Thing in the callback, but my hacks so far were not successful.

If I'm not mistaken the problem should happen in one of the two
gtk_distribute_natural_allocation calls of gtk_menu_bar_size_allocate.

But create_menus in gtkutil.c has this

           /* Set width of menu bar to a small value so it doesn't enlarge
              a small initial frame size.  The width will be set to the
              width of the frame later on when it is added to a container.
              height -1: Natural height.  */
           gtk_widget_set_size_request (wmenu, 1, -1);

I have no idea yet how these are related and when the "width will be set".

 > For starters, I think this should be documented in the Emacs manual
 > about frame parameters and in functions/variables like `set-frame-width'
 > and `initial-frame-alist'.

Could people test this with their favorite window managers?

martin