gtk3: too large menu covers menu bar
If menu from menu bar has a lot of items and is very high, shown as popup, covers menu bar. This is regression from GTK2, where it was good. I created patch for it.
How to reproduce:
- Install and start LibreOffice Writer. Make sure it uses GTK3* integration plugin (just try to see file chooser appearance).
- Set screen resolution to something like 1366 x 768 OR resize LO Writer window to size like this and move window to right-bottom screen corner.
- Open Insert menu. -> screenshot libreoffice-writer-gtk3.png
- Apply my patch to GTK3.
- Repeat 1, 2, 3. -> screenshot libreoffice-writer-gtk3-fixed.png
* - LO uses its own toolkit to draw widgets. But with GTK3 integration it uses GTK3 widgets directly and natively to draw menus, menu bars and context menus.
Tested on:
- OS: Arch Linux, Manjaro;
- WMs: Marco, xfwm4, Mutter;
- GTK3 version: the newest stable and older versions also.
There was a piece of code in GTK2 which was handling this situation properly. It is here (gtkmenuitem.c, lines 1764-1767): https://github.com/GNOME/gtk/blob/gtk-2-24/gtk/gtkmenuitem.c#L1764
It seems to me code like this doesn't exist in GTK3. I created patch for it. My patch is here: https://github.com/TomaszGasior/gtk3-mushrooms/blob/master/fixes__too-large-menu-covers-bar.patch
There are problems with it:
- I am weak in C/GLib/GTK and friends so quality of this code can be bad. But I have no better idea how to solve it.
- If you move window to bottom screen corner, open long menu, then move window to top screen corner and second time open menu, size of menu is too small (it is adjusted to previous free space, not to current) — I don't know how to reset it.
- GTK2 code was handling situation when popup menu should be shown above menu bar (not only under menu bar) — my code can't do this.
- My code can't handle RTL.
(This issue is copied from BugZilla: https://bugzilla.gnome.org/show_bug.cgi?id=792764 )