From a89aa1d8cccd7926be505b4c7878d4e7f4dd1840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 22 Jan 2016 10:35:05 +0800 Subject: [PATCH] wayland/wl_shell: Dismiss popup when parent is destroyed Dismiss the popup when the parent is destroyed, and do this in the destructor of the parent object. This makes the parent destory listener unnecessary, since we already handle the parent child unlinking explicitly in the object destructor. https://bugzilla.gnome.org/show_bug.cgi?id=763431 --- src/wayland/meta-wayland-wl-shell.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/wayland/meta-wayland-wl-shell.c b/src/wayland/meta-wayland-wl-shell.c index 6b1d16733..bc5a17169 100644 --- a/src/wayland/meta-wayland-wl-shell.c +++ b/src/wayland/meta-wayland-wl-shell.c @@ -69,6 +69,12 @@ wl_shell_surface_destructor (struct wl_resource *resource) MetaWaylandSurface *child_surface = l->data; child_surface->wl_shell.parent_surface = NULL; + + if (child_surface->popup.parent == surface) + { + meta_wayland_popup_dismiss (child_surface->popup.popup); + child_surface->popup.parent = NULL; + } } if (surface->wl_shell.parent_surface) @@ -84,7 +90,6 @@ wl_shell_surface_destructor (struct wl_resource *resource) if (surface->popup.popup) { - wl_list_remove (&surface->popup.parent_destroy_listener.link); surface->popup.parent = NULL; meta_wayland_popup_dismiss (surface->popup.popup); @@ -252,17 +257,6 @@ wl_shell_surface_set_fullscreen (struct wl_client *client, META_WL_SHELL_SURFACE_STATE_FULLSCREEN); } -static void -handle_wl_shell_popup_parent_destroyed (struct wl_listener *listener, - void *data) -{ - MetaWaylandSurface *surface = - wl_container_of (listener, surface, popup.parent_destroy_listener); - - wl_list_remove (&surface->popup.parent_destroy_listener.link); - surface->popup.parent = NULL; -} - static void create_popup (MetaWaylandSurface *surface) { @@ -300,7 +294,6 @@ wl_shell_surface_set_popup (struct wl_client *client, if (surface->popup.popup) { surface->popup.parent = NULL; - wl_list_remove (&surface->popup.parent_destroy_listener.link); meta_wayland_popup_dismiss (surface->popup.popup); } @@ -314,12 +307,6 @@ wl_shell_surface_set_popup (struct wl_client *client, return; } - surface->popup.parent = parent_surf; - surface->popup.parent_destroy_listener.notify = - handle_wl_shell_popup_parent_destroyed; - wl_resource_add_destroy_listener (parent_surf->resource, - &surface->popup.parent_destroy_listener); - set_wl_shell_surface_parent (surface, parent_surf); surface->wl_shell.popup_seat = seat; surface->wl_shell.x = x;