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 772146 - Standalone GtkMenu doesn't disappear when clicking outside of it
Standalone GtkMenu doesn't disappear when clicking outside of it
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.24.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-09-28 21:03 UTC by Andrej Kacian
Modified: 2018-04-15 00:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (785 bytes, text/x-csrc)
2016-09-28 21:03 UTC, Andrej Kacian
Details

Description Andrej Kacian 2016-09-28 21:03:15 UTC
Created attachment 336474 [details]
Test case

If I have a standalone GtkMenu, displayed via gtk_menu_popup() (e.g. in GtkStatusIcon's "popup-menu" signal handler), it doesn't go away unless you either select one of its items, or you click inside another GTK window. Clicking e.g. on empty desktop, or on taskbar doesn't make it disappear.

This can only be reproduced if no other window belonging to the same application is focused. Attached test case shows the issue. It lets the menu appear when a toplevel window loses focus. If you comment out the g_signal_connect() call and uncomment gtk_menu_popup() call below it, you can test that it works fine if the menu gets popped up while a toplevel window has focus - menu disappears when clicking on an empty desktop.

Tried on GTK+ 2.24.30, and I do not see anything in .31 that could have fixed it.

I think this might be related to issue solved in old bug report #107320.
Comment 1 LRN 2016-09-29 00:30:41 UTC
If your use-case is *specifically* the popup menu from a tray icon that doesn't go away when user clicks outside of it- that bug is OlderThanFeudalism, and GTK2 had it for as long as i can remember. All applications that do popup menu from a tray icon have a hacky workaround for this (Pidgin, for example).

Without digging through bugzilla, from the top of my head, the issue was that to correctly detect the moment when an outside-click is made, the menu window has to do a more-encompassing mouse capture than the one it already does (because normally windows don't get clicks outside of themselves; i'm not sure why keyboard focus wasn't used as a stand-in, maybe popups don't get it initially). I've tried to find a clean app-level workaround for that back in the day (before i started to hack on GTK itself), and failed.

Tray icons are deprecated in GTK3 and will be removed in GTK4, AFAIK.
Comment 2 Matthias Clasen 2018-02-10 05:04:42 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 3 Matthias Clasen 2018-04-15 00:23:27 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new