GNOME Bugzilla – Bug 377349
gtk_status_icon_position_menu is not implemented for Win32
Last modified: 2007-02-10 10:01:32 UTC
if you run the attached sample in Windows menu is shown in wrong position. in Linux that works great. I use GTK installer from gladewin32.sf.net
Created attachment 76906 [details] see top right
Created attachment 76907 [details] sample script
gtk_status_icon_position_menu() is not implemented for Win32. Patches welcome.
Tor, can't you at least put it under mouse coordinates as opposed to putting it somewhere random or super misplaced? all this until it's hacked in win32 to work.
Apparently there is no documented official way to find out the location of a tray icon. http://www.codeproject.com/shell/ctrayiconposition.asp?df=100&forumid=14631&exp=0&select=1002102 has some relatiely complex and hackish code, maybe that could be used. Don't know how well that can be expected to work in all Windows versions and with various 3rd-party addons and "desktop enhancements" end-users might be running, though. However, in the special case of wanting to know the tray icon's position right after the user has clicked on it, we can simply call GetCursorPos() in the tray icon's message handler. So maybe what we should do is just do what in wndproc() in gtkstatusicon.c, cache the position, and return it in gtk_status_icon_position_menu()? It's simple, better than nothing (= the current code), and presumably covers the use case in this bug. (I can't run the test program, as the Python gtk module I happen to have doesn't wrap the 2.10 -only gtk_status_icon_position_menu() API, and I'm too lazy to start upgrading that now.)
Yes, what you propose clearly is better than nothing and seems simple. FYI http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.2/ http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.12/ http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.10/ I was also wondering if you plan to fix, or if it's even reported, that trayicon menu does not pop down, when user clicks somewhere else (outside of the menu). This happens with normal tray icon menus (from other non GTK related libraries), but not with the Status Icon API ones.
I don't think that other problem has been reported, please open a bug for it (and include a miminal test program).
Thanks for the links, installing fresh GTK+ etc bindings for Python was trivial. Fixed (well, for the presumably most common use case) in HEAD and gtk-2-10: 2006-12-27 Tor Lillqvist <tml@novell.com> * gtk/gtkstatusicon.c: Implement gtk_status_icon_position_menu() on Windows. Keep track of where the last button click on the taskbar icon took place, and return that. Obviously not correct if no button has ever been clicked on the icon, or if the geometry of the taskbar has changed since. But for most use cases where a menu is going to be displayed as a direct result of a button click on the status icon, works fine. (#377349)
*** Bug 406062 has been marked as a duplicate of this bug. ***