From 0c213c8feee6c11eef19fb316f3514e2a9cb0f27 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 7 Feb 2014 17:28:33 -0500 Subject: [PATCH] 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 851b2cebb..5c21f4ebc 100644 --- a/protocol/xdg-shell.xml +++ b/protocol/xdg-shell.xml @@ -373,6 +373,19 @@ decorations should be updated accordingly. + + + + 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... + + diff --git a/src/core/delete.c b/src/core/delete.c index 437becf1e..a24c1b97e 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -37,6 +37,8 @@ #include #include +#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 2920e2a87..cd7229813 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 172201386..c87854bb1 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