summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2015-10-18 21:03:52 +0800
committerJonas Ådahl <jadahl@gmail.com>2015-10-27 08:41:02 +0800
commite25ea62f22ce0bbb7175f93c07de5cab773778a7 (patch)
tree4586cb6522022a1f1d61b37ac56f0b07625ea98e /gdk
parent49798754e6176147d1ff34581f2f4ed715ebb9b7 (diff)
downloadgtk+-e25ea62f22ce0bbb7175f93c07de5cab773778a7.tar.gz
wayland: Don't try to use subsurfaces as popup parents
If a GtkMenu (or something else that is mapped as a xdg_popup) tries to use a subsurface window as a parent, it will be terminated by the compositor due to protocol violation. So to avoid this, if a parent window is not a xdg_popup or xdg_surface, i.e. a wl_subsurface, then traverse up the transient parents until we find the right popup parent. https://bugzilla.gnome.org/show_bug.cgi?id=756780
Diffstat (limited to 'gdk')
-rw-r--r--gdk/wayland/gdkwindow-wayland.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index b8d5030577..ce4c8fef9f 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1258,6 +1258,27 @@ should_map_as_popup (GdkWindow *window)
return FALSE;
}
+/* Get the window that can be used as a parent for a popup, i.e. a xdg_surface
+ * or xdg_popup. If the window is not, traverse up the transiency parents until
+ * we find one.
+ */
+static GdkWindow *
+get_popup_parent (GdkWindow *window)
+{
+ do
+ {
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ if (impl->xdg_popup || impl->xdg_surface)
+ return window;
+
+ window = impl->transient_for;
+ }
+ while (window);
+
+ return NULL;
+}
+
static void
gdk_wayland_window_map (GdkWindow *window)
{
@@ -1322,6 +1343,8 @@ gdk_wayland_window_map (GdkWindow *window)
if (transient_for)
transient_for = gdk_window_get_toplevel (transient_for);
+ if (transient_for)
+ transient_for = get_popup_parent (transient_for);
/* If the position was not explicitly set, start the popup at the
* position of the device that holds the grab.
@@ -1332,7 +1355,7 @@ gdk_wayland_window_map (GdkWindow *window)
&window->x, &window->y, NULL);
}
else
- transient_for = impl->transient_for;
+ transient_for = get_popup_parent (impl->transient_for);
if (!transient_for)
{