After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703069 - Opening a big menu activates some menu entry
Opening a big menu activates some menu entry
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-06-25 16:48 UTC by Emilio Pozuelo Monfort
Modified: 2017-10-08 16:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot (145.83 KB, image/png)
2013-06-25 16:49 UTC, Emilio Pozuelo Monfort
  Details
menushell: don't activate a menu entry when opening a big menu (1.59 KB, patch)
2013-06-27 17:05 UTC, Emilio Pozuelo Monfort
committed Details | Review

Description Emilio Pozuelo Monfort 2013-06-25 16:48:44 UTC
(Couldn't find a bug for this, but there are so many menu bugs that I may have missed one...)

Say an application menu is a bit too big, or your screen resolution is a bit too small, or you have a non-maximized application placed such that the menu bar is in the middle of the screen, or your gtk+ theme makes menu be a bit bigger than usual, or any combination of those.

Now what happens if you click on that menu (e.g. "View") is that the menu popup doesn't fit entirely below "View", and it doesn't fit entirely above it either. What gtk+ does then is open it on top (which is fine). See the attached screenshot.

Let's see what happens when you click on the menu
a) button-press-event, gtk+ opens the menu. the mouse is now on top of one
   of the menu entries.
b) button-release-event, received by the menu entry. If the menu entry is a
   submenu, that gets opened, but if it's a normal entry, that gets activated
   and the menu is closed.

The effect is that the menu opens and closes really fast and depending on what was clicked, you may not know what's happened or you may have accidentally done something undesirable.
Comment 1 Emilio Pozuelo Monfort 2013-06-25 16:49:16 UTC
Created attachment 247757 [details]
screenshot
Comment 2 Emilio Pozuelo Monfort 2013-06-26 10:47:31 UTC
I think a good solution for this would be:

if (button-press originated in the menu shell) and (not long-press)
  ignore

or more generically:

if (button-press originated in the parent) and (not long-press)
  ignore

i.e. if we activate a menu (say "Edit") in the menu shell with button-press and then button-release activates a submenu entry (say "Copy"), we only activate it if it was a long press. If it's a short press but it was originated in the item itself (or perhaps in any item in the submenu, but not in the parent) we activate it.
Comment 3 Emilio Pozuelo Monfort 2013-06-27 17:05:39 UTC
Created attachment 247928 [details] [review]
menushell: don't activate a menu entry when opening a big menu

If a menu is opened and it doesn't fit entirely below or above
the menu bar, gtk+ will place it on top. The button release will
then activate the popup item that happens to appear under the
cursor. Avoid this by ignoring release events if they originated
in the parent menu bar and the duration of the press was too short.
Comment 4 Emilio Pozuelo Monfort 2013-06-27 17:10:14 UTC
I tried to implement the logic from comment #2 in the above patch. I will not claim to have covered every possible scenario or to have fully understood the gtkmenu* logic, but I have played with the menus and the above patch a bit and from my tests this solves the issue at hand and doesn't bring any regressions.
Comment 5 Emilio Pozuelo Monfort 2013-06-27 18:25:33 UTC
Reviewed by Benjamin on irc. Pushed to master and gtk-3-8.