From 044e4b15a65eb013411ea3cef3e7c2eebf6d5ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 26 Apr 2016 11:46:25 +0800 Subject: [PATCH] wayland: Track orphaned dialogs per display Don't track all orphaned dialogs globally, as mixing them up with each other would in most cases trigger errors when we try to pass bogus values to Wayland requests. https://bugzilla.gnome.org/show_bug.cgi?id=765474 --- gdk/wayland/gdkdisplay-wayland.h | 3 +++ gdk/wayland/gdkwindow-wayland.c | 31 ++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index 5410cf3fa4..2c23b14ce2 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -82,6 +82,9 @@ struct _GdkWaylandDisplay GHashTable *known_globals; GList *on_has_globals_closures; + /* Keep a list of orphaned dialogs (i.e. without parent) */ + GList *orphan_dialogs; + struct wl_cursor_theme *scaled_cursor_themes[GDK_WAYLAND_THEME_SCALES_COUNT]; gchar *cursor_theme_name; int cursor_theme_size; diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 8f944723e5..f05de065ad 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -191,14 +191,15 @@ _gdk_window_impl_wayland_init (GdkWindowImplWayland *impl) impl->saved_height = -1; } -/* Keep a list of orphaned dialogs (i.e. without parent) */ -static GList *orphan_dialogs; - static void _gdk_wayland_screen_add_orphan_dialog (GdkWindow *window) { - if (!g_list_find (orphan_dialogs, window)) - orphan_dialogs = g_list_prepend (orphan_dialogs, window); + GdkWaylandDisplay *display_wayland = + GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)); + + if (!g_list_find (display_wayland->orphan_dialogs, window)) + display_wayland->orphan_dialogs = + g_list_prepend (display_wayland->orphan_dialogs, window); } static void @@ -950,6 +951,9 @@ gdk_wayland_window_sync_parent (GdkWindow *window, GdkWindowImplWayland *impl_parent = NULL; struct xdg_surface *parent_surface; + g_assert (parent == NULL || + gdk_window_get_display (window) == gdk_window_get_display (parent)); + if (!impl->display_server.xdg_surface) return; @@ -975,12 +979,14 @@ gdk_wayland_window_sync_parent (GdkWindow *window, static void gdk_wayland_window_update_dialogs (GdkWindow *window) { + GdkWaylandDisplay *display_wayland = + GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)); GList *l; - if (!orphan_dialogs) + if (!display_wayland->orphan_dialogs) return; - for (l = orphan_dialogs; l; l = l->next) + for (l = display_wayland->orphan_dialogs; l; l = l->next) { GdkWindow *w = l->data; GdkWindowImplWayland *impl; @@ -1827,7 +1833,8 @@ gdk_wayland_window_hide_surface (GdkWindow *window) impl->display_server.outputs = NULL; if (impl->hint == GDK_WINDOW_TYPE_HINT_DIALOG && !impl->transient_for) - orphan_dialogs = g_list_remove (orphan_dialogs, window); + display_wayland->orphan_dialogs = + g_list_remove (display_wayland->orphan_dialogs, window); } _gdk_wayland_window_clear_saved_size (window); @@ -2288,8 +2295,13 @@ gdk_wayland_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + GdkWaylandDisplay *display_wayland = + GDK_WAYLAND_DISPLAY (gdk_window_get_display (window)); GdkWindow *previous_parent; + g_assert (parent == NULL || + gdk_window_get_display (window) == gdk_window_get_display (parent)); + if (check_transient_for_loop (window, parent)) { g_warning ("Setting %p transient for %p would create a loop", window, parent); @@ -2307,7 +2319,8 @@ gdk_wayland_window_set_transient_for (GdkWindow *window, if (!parent) _gdk_wayland_screen_add_orphan_dialog (window); else if (!previous_parent) - orphan_dialogs = g_list_remove (orphan_dialogs, window); + display_wayland->orphan_dialogs = + g_list_remove (display_wayland->orphan_dialogs, window); } gdk_wayland_window_sync_parent (window, NULL); if (should_map_as_subsurface (window) &&