From 9debd2fb0d2618774a1a9b721df67a5dbdfe092c Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 20 Mar 2014 15:07:44 -0400 Subject: [PATCH] Move delete / kill to be a vfunc --- src/core/delete.c | 51 ++------------------------------- src/core/window-private.h | 3 ++ src/wayland/window-wayland.c | 15 ++++++++++ src/x11/window-x11.c | 55 ++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 49 deletions(-) diff --git a/src/core/delete.c b/src/core/delete.c index 136e564ea..8b5070796 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -143,31 +143,7 @@ void meta_window_delete (MetaWindow *window, guint32 timestamp) { - if (window->client_type == META_WINDOW_CLIENT_TYPE_X11) - { - 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_wayland_surface_delete (window->surface); - } + META_WINDOW_GET_CLASS (window)->delete (window, timestamp); meta_window_check_alive (window, timestamp); @@ -200,33 +176,10 @@ meta_window_delete (MetaWindow *window, } } - void meta_window_kill (MetaWindow *window) { - meta_topic (META_DEBUG_WINDOW_OPS, - "Killing %s brutally\n", - window->desc); - - if (!meta_window_is_remote (window) && - window->net_wm_pid > 0) - { - meta_topic (META_DEBUG_WINDOW_OPS, - "Killing %s with kill()\n", - window->desc); - - if (kill (window->net_wm_pid, 9) < 0) - meta_topic (META_DEBUG_WINDOW_OPS, - "Failed to signal %s: %s\n", - window->desc, strerror (errno)); - } - - meta_topic (META_DEBUG_WINDOW_OPS, - "Disconnecting %s with XKillClient()\n", - window->desc); - meta_error_trap_push (window->display); - XKillClient (window->display->xdisplay, window->xwindow); - meta_error_trap_pop (window->display); + META_WINDOW_GET_CLASS (window)->kill (window); } void diff --git a/src/core/window-private.h b/src/core/window-private.h index aa57332eb..82bfbdebf 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -471,6 +471,9 @@ struct _MetaWindowClass void (*manage) (MetaWindow *window); void (*unmanage) (MetaWindow *window); + void (*delete) (MetaWindow *window, + guint32 timestamp); + void (*kill) (MetaWindow *window); void (*move_resize_internal) (MetaWindow *window, int gravity, MetaRectangle requested_rect, diff --git a/src/wayland/window-wayland.c b/src/wayland/window-wayland.c index 8b75da743..eea45f31e 100644 --- a/src/wayland/window-wayland.c +++ b/src/wayland/window-wayland.c @@ -75,6 +75,19 @@ meta_window_wayland_unmanage (MetaWindow *window) meta_display_unregister_wayland_window (window->display, window); } +static void +meta_window_wayland_delete (MetaWindow *window, + guint32 timestamp) +{ + meta_wayland_surface_delete (window->surface); +} + +static void +meta_window_wayland_kill (MetaWindow *window) +{ + /* TODO */ +} + static void meta_window_wayland_move_resize_internal (MetaWindow *window, int gravity, @@ -176,5 +189,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass) window_class->manage = meta_window_wayland_manage; window_class->unmanage = meta_window_wayland_unmanage; + window_class->delete = meta_window_wayland_delete; + window_class->kill = meta_window_wayland_kill; window_class->move_resize_internal = meta_window_wayland_move_resize_internal; } diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 86491a665..e95fdec3a 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -322,6 +322,59 @@ meta_window_x11_unmanage (MetaWindow *window) meta_error_trap_pop (window->display); } +static void +meta_window_x11_delete (MetaWindow *window, + guint32 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); +} + +static void +meta_window_x11_kill (MetaWindow *window) +{ + meta_topic (META_DEBUG_WINDOW_OPS, + "Killing %s brutally\n", + window->desc); + + if (!meta_window_is_remote (window) && + window->net_wm_pid > 0) + { + meta_topic (META_DEBUG_WINDOW_OPS, + "Killing %s with kill()\n", + window->desc); + + if (kill (window->net_wm_pid, 9) < 0) + meta_topic (META_DEBUG_WINDOW_OPS, + "Failed to signal %s: %s\n", + window->desc, strerror (errno)); + } + + meta_topic (META_DEBUG_WINDOW_OPS, + "Disconnecting %s with XKillClient()\n", + window->desc); + + meta_error_trap_push (window->display); + XKillClient (window->display->xdisplay, window->xwindow); + meta_error_trap_pop (window->display); +} + static void update_net_frame_extents (MetaWindow *window) { @@ -744,6 +797,8 @@ meta_window_x11_class_init (MetaWindowX11Class *klass) window_class->manage = meta_window_x11_manage; window_class->unmanage = meta_window_x11_unmanage; + window_class->delete = meta_window_x11_delete; + window_class->kill = meta_window_x11_kill; window_class->move_resize_internal = meta_window_x11_move_resize_internal; window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints; }