From 35c4627fac119a7259fc0450e26091ea58173069 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Fri, 29 Mar 2019 22:38:32 +0100 Subject: [PATCH] gdk/wayland: Properly calculate coordinates for show_window_menu() The event received in `gdk_wayland_window_show_window_menu()` can come from widgets with a GdkWindow. In those cases the coordinates are relative to the widget, not the root window. This results in a misplaced window menu. Properly calculate the coordinates by iterating to the toplevel window as suggested by Carlos Garnacho. https://gitlab.gnome.org/GNOME/gtk/merge_requests/684 --- gdk/wayland/gdkwindow-wayland.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 70f1044d9b..7007f30ce3 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -4478,6 +4478,12 @@ gdk_wayland_window_show_window_menu (GdkWindow *window, seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device)); gdk_event_get_coords (event, &x, &y); + while (gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL) + { + gdk_window_coords_to_parent (window, x, y, &x, &y); + window = gdk_window_get_effective_parent (window); + } + serial = _gdk_wayland_device_get_implicit_grab_serial (device, event); switch (display_wayland->shell_variant)