Patch-Source: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6184 https://gitlab.gnome.org/GNOME/gimp/-/issues/6711 -- From 3e3266dce4a8aed453f296ca8043e3574ff29f63 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 13 Jul 2023 15:31:05 +0200 Subject: [PATCH 1/2] GdkWindow: Check for offscreen windows in set_transient_for () Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/6711 --- gdk/gdkwindow.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 727b0cf1f43..62d488d7594 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -10542,6 +10542,13 @@ void gdk_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { + if (!gdk_window_is_offscreen (window) && + parent != NULL && + gdk_window_is_offscreen (parent)) + { + return; + } + window->transient_for = parent; GDK_WINDOW_IMPL_GET_CLASS (window->impl)->set_transient_for (window, parent); -- GitLab From 272b6b4febb3e293239e178410f87abcad85ba2d Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 13 Jul 2023 16:24:55 +0200 Subject: [PATCH 2/2] GtkMenu: Take offscreen windows in account for positioning --- gtk/gtkmenu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index eac972bb41b..3f1a7bc9fac 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -5263,6 +5263,24 @@ gtk_menu_position (GtkMenu *menu, } } + if (rect_window != NULL && + GDK_WINDOW_TYPE (rect_window) == GDK_WINDOW_OFFSCREEN) + { + GdkWindow *effective = gdk_offscreen_window_get_embedder (rect_window); + + if (effective) + { + double x = rect.x, y = rect.y; + + gdk_window_coords_to_parent (rect_window, x, y, &x, &y); + + rect.x = x; + rect.y = y; + } + + rect_window = effective; + } + if (!rect_window) { gtk_window_set_unlimited_guessed_size (GTK_WINDOW (priv->toplevel), -- GitLab