[mutter] wayland: Let the popup surface explicitly dismiss the popup



commit 61c717abb355eff5d45344270e3f72e73db8972a
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Jan 21 17:03:16 2016 +0800

    wayland: Let the popup surface explicitly dismiss the popup
    
    Instead of relying on destroy signals attached to the corresponding
    role object, let the roles explicitly dismiss the popup when it should
    be dismissed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763431

 src/wayland/meta-wayland-popup.c    |   23 -----------------------
 src/wayland/meta-wayland-wl-shell.c |   15 ++++++++++++++-
 2 files changed, 14 insertions(+), 24 deletions(-)
---
diff --git a/src/wayland/meta-wayland-popup.c b/src/wayland/meta-wayland-popup.c
index 93fea93..6c4b784 100644
--- a/src/wayland/meta-wayland-popup.c
+++ b/src/wayland/meta-wayland-popup.c
@@ -62,7 +62,6 @@ struct _MetaWaylandPopupGrab
 struct _MetaWaylandPopup
 {
   MetaWaylandPopupGrab *grab;
-  struct wl_listener surface_destroy_listener;
   MetaWaylandPopupSurface *popup_surface;
   struct wl_list link;
 };
@@ -231,7 +230,6 @@ meta_wayland_popup_destroy (MetaWaylandPopup *popup)
 {
   meta_wayland_popup_surface_dismiss (popup->popup_surface);
 
-  wl_list_remove (&popup->surface_destroy_listener.link);
   wl_list_remove (&popup->link);
   g_slice_free (MetaWaylandPopup, popup);
 }
@@ -253,16 +251,6 @@ meta_wayland_popup_get_top_popup (MetaWaylandPopup *popup)
   return meta_wayland_popup_grab_get_top_popup (popup->grab);
 }
 
-static void
-on_popup_surface_destroy (struct wl_listener *listener,
-                         void               *data)
-{
-  MetaWaylandPopup *popup =
-    wl_container_of (listener, popup, surface_destroy_listener);
-
-  meta_wayland_popup_dismiss (popup);
-}
-
 MetaWaylandPopup *
 meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
                            MetaWaylandPopupGrab    *grab)
@@ -278,17 +266,6 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
   popup = g_slice_new0 (MetaWaylandPopup);
   popup->grab = grab;
   popup->popup_surface = popup_surface;
-  popup->surface_destroy_listener.notify = on_popup_surface_destroy;
-  if (surface->xdg_popup)
-    {
-      wl_resource_add_destroy_listener (surface->xdg_popup,
-                                        &popup->surface_destroy_listener);
-    }
-  else if (surface->wl_shell_surface)
-    {
-      wl_resource_add_destroy_listener (surface->wl_shell_surface,
-                                        &popup->surface_destroy_listener);
-    }
 
   wl_list_insert (&grab->all_popups, &popup->link);
 
diff --git a/src/wayland/meta-wayland-wl-shell.c b/src/wayland/meta-wayland-wl-shell.c
index c3f40bf..6b1d167 100644
--- a/src/wayland/meta-wayland-wl-shell.c
+++ b/src/wayland/meta-wayland-wl-shell.c
@@ -61,6 +61,9 @@ wl_shell_surface_destructor (struct wl_resource *resource)
   meta_wayland_compositor_destroy_frame_callbacks (surface->compositor,
                                                    surface);
 
+  if (surface->popup.popup)
+    meta_wayland_popup_dismiss (surface->popup.popup);
+
   for (l = surface->wl_shell.children; l; l = l->next)
     {
       MetaWaylandSurface *child_surface = l->data;
@@ -168,6 +171,13 @@ wl_shell_surface_set_state (MetaWaylandSurface     *surface,
 
   if (surface->window && old_state != state)
     {
+      if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP &&
+          surface->popup.popup)
+        {
+          meta_wayland_popup_dismiss (surface->popup.popup);
+          surface->popup.popup = NULL;
+        }
+
       if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN)
         meta_window_make_fullscreen (surface->window);
       else
@@ -498,7 +508,10 @@ wl_shell_surface_role_commit (MetaWaylandSurfaceRole  *surface_role,
     }
   else if (!surface->buffer_ref.buffer && window)
     {
-      meta_wayland_surface_destroy_window (surface);
+      if (surface->popup.popup)
+        meta_wayland_popup_dismiss (surface->popup.popup);
+      else
+        meta_wayland_surface_destroy_window (surface);
       return;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]