[mutter/xdg-shell: 2/3] wayland: Add support for the delete event



commit 0c213c8feee6c11eef19fb316f3514e2a9cb0f27
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 7 17:28:33 2014 -0500

    wayland: Add support for the delete event

 protocol/xdg-shell.xml             |   13 +++++++++++++
 src/core/delete.c                  |   35 ++++++++++++++++++++++-------------
 src/wayland/meta-wayland-surface.c |    7 +++++++
 src/wayland/meta-wayland-surface.h |    1 +
 4 files changed, 43 insertions(+), 13 deletions(-)
---
diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml
index 851b2ce..5c21f4e 100644
--- a/protocol/xdg-shell.xml
+++ b/protocol/xdg-shell.xml
@@ -373,6 +373,19 @@
        decorations should be updated accordingly.
       </description>
     </event>
+
+    <event name="delete">
+      <description summary="surface wants to be closed">
+        The delete event is sent by the compositor when the user
+        wants the surface to be closed. This should be equivalent to
+        the user clicking the close button in client-side decorations,
+        if your application has any...
+
+        This is only a request that the user intends to close your
+        window. The client may choose to ignore this request, or show
+        a dialog to ask the user to save their data...
+      </description>
+    </event>
   </interface>
 
   <interface name="xdg_popup" version="1">
diff --git a/src/core/delete.c b/src/core/delete.c
index 437becf..a24c1b9 100644
--- a/src/core/delete.c
+++ b/src/core/delete.c
@@ -37,6 +37,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "meta-wayland-surface.h"
+
 static void meta_window_present_delete_dialog (MetaWindow *window,
                                                guint32     timestamp);
 
@@ -141,24 +143,31 @@ void
 meta_window_delete (MetaWindow  *window,
                     guint32      timestamp)
 {
-  meta_error_trap_push (window->display);
-  if (window->delete_window)
+  if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
     {
-      meta_topic (META_DEBUG_WINDOW_OPS,
-                  "Deleting %s with delete_window request\n",
-                  window->desc);
-      meta_window_send_icccm_message (window,
-                                      window->display->atom_WM_DELETE_WINDOW,
-                                      timestamp);
+      meta_error_trap_push (window->display);
+      if (window->delete_window)
+        {
+          meta_topic (META_DEBUG_WINDOW_OPS,
+                      "Deleting %s with delete_window request\n",
+                      window->desc);
+          meta_window_send_icccm_message (window,
+                                          window->display->atom_WM_DELETE_WINDOW,
+                                          timestamp);
+        }
+      else
+        {
+          meta_topic (META_DEBUG_WINDOW_OPS,
+                      "Deleting %s with explicit kill\n",
+                      window->desc);
+          XKillClient (window->display->xdisplay, window->xwindow);
+        }
+      meta_error_trap_pop (window->display);
     }
   else
     {
-      meta_topic (META_DEBUG_WINDOW_OPS,
-                  "Deleting %s with explicit kill\n",
-                  window->desc);
-      XKillClient (window->display->xdisplay, window->xwindow);
+      meta_wayland_surface_delete (window->surface);
     }
-  meta_error_trap_pop (window->display);
 
   meta_window_check_alive (window, timestamp);
 
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 2920e2a..cd72298 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1464,3 +1464,10 @@ meta_wayland_surface_ping (MetaWaylandSurface *surface,
   else if (surface->xdg_popup.resource)
     xdg_popup_send_ping (surface->xdg_popup.resource, timestamp);
 }
+
+void
+meta_wayland_surface_delete (MetaWaylandSurface *surface)
+{
+  if (surface->xdg_surface.resource)
+    xdg_surface_send_delete (surface->xdg_surface.resource);
+}
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 1722013..c87854b 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -115,5 +115,6 @@ void                meta_wayland_surface_focused_unset (MetaWaylandSurface *surf
 
 void                meta_wayland_surface_ping (MetaWaylandSurface *surface,
                                                guint32             serial);
+void                meta_wayland_surface_delete (MetaWaylandSurface *surface);
 
 #endif


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