GNOME Bugzilla – Bug 377416
gtk menu that is popped up using StatusIcon API should popdown when user clicks somewhere outside of menu
Last modified: 2014-08-30 05:20:18 UTC
In your tray area, right click one application you have. You see a menu, then click on the desktop. You see that menu gets hidden (popped down). Now run the sample, notice how Hi remains on the top right no matter what (you have to click the menuitem to get it to disappear!)
Created attachment 76916 [details] demo so you can reproduce.
I guess we need to intercept clicks to non-GTK windows (i.e the Desktop). Maybe a focus-out event is enough?
I am not sure that any such the process will receive any such messages corresponding to focus-out. I would be loved to be proved wrong, though. As always, patches welcome.
I'm not a Windows API expert, but I could imagine something like this: "register to catching any click. get X, Y and see if those coordinates belong outside the menu". Since all other libraries do it, maybe it is somehow easy to find.
Which other libraries do what?
qt (open source for windows) provides an API that does all the trayicon functionality correctly.
Anybody, feel free to have a look at the Qt sources then and work on a patch to make it work in GTK+ too.
gtkmm-2.14 win32 visual studio 2008 (c++) I ran into this exact bug the other day trying to do a quick demo with c++/gtkmm on win32, similar code path to the python example already posted; nothing short of clicking on a menu item makes the menu popdown. The menu also doesn't respond to the arrow keys, making me wonder if there's an underlying focus issue -- the same code under linux handles the arrow keys and does a popdown automatically when the menu loses focus.
The X11 and Win32 implementations of the status icon API are very different, so it isn't any wonder that they work differently.
*** Bug 578070 has been marked as a duplicate of this bug. ***
Is there any reason to leave this UNCONFIRMED still, with so many confirmations of the problem? I'm tempted to change it to NEW but am not familiar with the GTK+ team's bug practices.
UNCONFIRMED and NEW have pretty much the same meaning for GTK+ bugs.
Changing popup menus from WS_POPUP to WS_OVERLAPPED (and undecorating it, of course) completely solved the focusing problem (overlapped popup receives keyboard focus as intended) and partially solved the problem of the popup staying opened (overlapped popup DOES react when user clicks outside of it, but at the moment i am unable to harness this reaction and turn it into the window being popped down; also somewhere something keeps sending it SW_SHOWWINDOW with wParam=0, effectively closing the window, to circumvent that i had to stop propagation of the grab-broken-event).
It's definitely some sort of focusing/activation issue, things work correctly on x11. I have also noticed that if you click on the menu somewhere that won't cause the menu to close (say, a seperator), you can then click on the desktop and the menu will correctly go away. Keyboard shortcuts are still non-functional though.
GtkStatusIcon has been deprecated