Skip to content

[regression gtk2->gtk3] gtk_menu_reposition() has no effect

John Lindgren requested to merge jlindgren90/gtk:fix-gtkmenu-resize into gtk-3-24

In GTK2, gtk_menu_reposition() was useful for realigning a menu if it changed size while already open (due to items having been added or removed).

In GTK3 however, already-open menus don't change size when items are added or removed. Instead, newly-added menu items are invisible (because the menu is too small to show them), and tiny scroll indicators appear. In my opinion, this a regression from a usability standpoint, because it can be tricky to hover the mouse over the tiny scroll indicator for just the right amount of time to get to the menu item you want.

It also seems that, as a result, gtk_menu_reposition() is pretty much useless in GTK3, because the main purpose for the function (as far as I can see) was to realign an already-open menu after it had changed size.

I don't know if it makes sense to revert exactly to the GTK2 behavior (where the menu changes size automatically), because that could result in misaligned menus if gtk_menu_reposition() isn't called. I would suggest, as a compromise solution, that calling gtk_menu_reposition() should also adjust the size of the menu to fit new items. That's what I've implemented in this merge request.


Test cases to reproduce the issue (click on the menu before the 5-second delay elapses): https://gitlab.gnome.org/jlindgren90/gtkmenu-resize-test

Screenshot with GTK2 (left) vs GTK3 (right): gtk2 gtk3

Merge request reports