GNOME Bugzilla – Bug 763851
GDK W32: show_window_menu() is not implemented
Last modified: 2016-03-29 14:30:18 UTC
This results in GTK using fallback window popup menu, which is very feature-poor (even if its implementation is improved).
Created attachment 324229 [details] [review] GDK W32: Implement show_window_menu() This is achieved by sending undocumented message 0x313 to the window. Before doing that, the window is given WS_SYSMENU style (to enable window menu) and some combination of WS_MAXIMIZEBOX (for "Mazimize" item) WS_MINIMIZEBOX (for "Minimize" item) WS_SIZEBOX (for "Size" item) depending on which operations are currently permissible. 0x313 is processed by DefWindowProc(), which results in showing the window menu. We remove extra styles at the first opportunity (WM_INITMENU message), as they alter the way our window is rendered.
Created attachment 324230 [details] [review] GDK W32: Implement show_window_menu() v2: * Use this for non-layered windows as well Now, the last thing after this is to see how it works for non-CSD windows.
Created attachment 324231 [details] [review] GDK W32: Implement show_window_menu() v3: * Make it work more or less correctly on non-CSD windows (see comments in the code for the description of some corner cases that are probably handled incorrectly).
Review of attachment 324231 [details] [review]: Hi LRN, Please see my comments about this. ::: gdk/win32/gdkevents-win32.c @@ +1910,3 @@ +static gboolean +handle_0x313 (GdkWindow *window, MSG *msg, gint *ret_valp) +{ For the 0x313, since that is undocumented, it means that MS might change this value at some point, and 0x313 is not a value that is that easy to remember what it really does. Perhaps it would be better if we define a constant/variable (that is easier to remember for this case) to 0x313, and add the new value(s) (or enum) when the value is changed or is designated a enum.
Created attachment 324238 [details] [review] GDK W32: Implement show_window_menu() v4: * 0x313 -> WM_SYSMENU * Set have_temp_styles to FALSE at the end of handle_wm_sysmenu() * Nicer WM_INITMENU handling (easier to extend later)
This patch has a bug - if you rightclick not on the headerbar, but on a button inside of the headerbar, menu is not positioned correctly (i.e. the code confuses the offset from topleft of a widget and the offset from topleft of a window).
Created attachment 324778 [details] [review] GDK W32: Implement show_window_menu() v5: * Fixed a bug: uses root event coords instead of getting event coords and then trying to rootify them.
If we define a constant ourselves, it would be better to use a prefix go avoid clash with constants ms might define in the future
WM_SYSMENU is not a random name. It was pried out of some MS table matches message names and codes[1]. I don't expect it to change, and if some headers do define it, they will define it to this value. [1] http://blog.airesoft.co.uk/2009/11/wm_messages/
Review of attachment 324778 [details] [review]: ::: gdk/win32/gdkprivate-win32.h @@ -98,2 +98,3 @@ #endif +#ifndef WM_SYSMENU Would be good to have a link to some kind of reference albeit unofficial ::: gdk/win32/gdkwindow-win32.h @@ -175,1 +180,5 @@ guint suppress_layered; + + /* Temporary styles that this window got for the purpose of + * handling WM_SYSMENU. + * They are removed at the opportunity (usually WM_INITMENU). I guess you meant "first opportunity"
Created attachment 324937 [details] [review] GDK W32: Implement show_window_menu() v6: * Fixed a missing word in a comment * Added a comment about WM_SYSMENU, with links to the sources of information about WM_SYSMENU.
Since all nitpicks were fixed, and no one gave any other objections, attachment 324937 [details] [review] pushed as cea8c29 - GDK W32: Implement show_window_menu()