Created attachment 149407 [details] Test program which does what I want to do on Firefox (Please move the component if I got it wrong) SUMMARY GTK has a `gdk_window_show_window_menu` API, which is useful to show the context menu on applications that use CSD: * https://docs.gtk.org/gdk3/method.Window.show_window_menu.html On Wayland, this is implemented via `xdg_toplevel::show_window_menu` and it works as expected on KWin: https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:show_window_menu On X11, however, it's implemented using a WM hint+message called `_GTK_SHOW_WINDOW_MENU`, used like this: https://gitlab.gnome.org/GNOME/gtk/-/blob/ad5c3168a9f21c3f387df09ce5cd501a9ea1b2d8/gdk/x11/gdksurface-x11.c#L4769-4796 For parity, it'd be great to have it supported on X11 too. One example where this doesn't work is Firefox's PiP window. Right-clicking there on KWin-on-Wayland, or in GNOME (Wayland or X11), shows the native context-menu to allow to move / position / etc the window. I wanted to extend this so that we also allow showing the native menu where using CSD / not showing the native titlebar in https://phabricator.services.mozilla.com/D147771. However on Plasma+X11 it doesn't do anything, which is unfortunate. STEPS TO REPRODUCE 1. `python <test-program>` 2. Right-click on the window area. See a context menu pop up. 3. Click on the context menu item. OBSERVED RESULT Nothing EXPECTED RESULT A popup, like on Wayland, with the native menu. SOFTWARE/OS VERSIONS Linux/KDE Plasma: Trunk
Happy to try fixing this with some pointers btw.
Find the code for X11 frame extents: 84d75cb5674577098d584c7f3634ea2a81d8b9f2 then it's mostly a c&p job. that'll show you roughly what's needed: - create the right atom in atoms.cpp - announce we support it in netinfo.cpp - watch for the new X11 event in events.cpp Then call into the existing code we have for wayland to show a menu
Thanks! For my own reference, that's https://invent.kde.org/plasma/kwin/-/commit/84d75cb5674577098d584c7f3634ea2a81d8b9f2
Ok, I think this should do. Works properly with a local build and: * https://invent.kde.org/frameworks/kwindowsystem/-/merge_requests/58 * https://invent.kde.org/plasma/kwin/-/merge_requests/2495 There's a test failure in the former MR which I need to investigate, seems I just need to add the expected atom somewhere.
(In reply to Emilio Cobos Álvarez (:emilio) from comment #4) > There's a test failure in the former MR which I need to investigate, seems I > just need to add the expected atom somewhere. (This is now fixed)
Git commit c3fa9cada231ba14f281d1a2fc46e240d0440517 by Emilio Cobos Álvarez. Committed on 10/06/2022 at 12:55. Pushed by davidedmundson into branch 'master'. Implement _GTK_SHOW_WINDOW_MENU. M +4 -0 autotests/netrootinfotestwm.cpp M +2 -0 src/netwm_def.h M +1 -0 src/platforms/xcb/atoms_p.h M +31 -0 src/platforms/xcb/netwm.cpp M +30 -0 src/platforms/xcb/netwm.h https://invent.kde.org/frameworks/kwindowsystem/commit/c3fa9cada231ba14f281d1a2fc46e240d0440517
Git commit 7e1617c2808b7c9b23a8c786327fc88212e10b32 by Vlad Zahorodnii, on behalf of Emilio Cobos Álvarez. Committed on 14/06/2022 at 06:55. Pushed by vladz into branch 'master'. [x11] Implement _GTK_SHOW_WINDOW_MENU. M +10 -1 src/netinfo.cpp M +1 -0 src/netinfo.h M +7 -0 src/x11window.cpp M +1 -0 src/x11window.h https://invent.kde.org/plasma/kwin/commit/7e1617c2808b7c9b23a8c786327fc88212e10b32