From e9944350d394b3d1668b5fd179a95137d4c5fbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 8 Oct 2016 17:32:27 +0200 Subject: [PATCH] delete: Share some code between X11 and wayland In order to kill a window, on both X11 and wayland we first try to kill(3) the corresponding process, so we can add the newly added get_client_pid() method to share that code. https://bugzilla.gnome.org/show_bug.cgi?id=772613 --- src/core/delete.c | 16 ++++++++++++++++ src/wayland/meta-window-wayland.c | 18 ------------------ src/x11/window-x11.c | 17 ----------------- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/core/delete.c b/src/core/delete.c index 141cd490b..a6a06083e 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -185,6 +185,22 @@ meta_window_delete (MetaWindow *window, void meta_window_kill (MetaWindow *window) { + pid_t pid = meta_window_get_client_pid (window); + + if (pid > 0) + { + meta_topic (META_DEBUG_WINDOW_OPS, + "Killing %s with kill()\n", + window->desc); + + if (kill (pid, 9) == 0) + return; + + meta_topic (META_DEBUG_WINDOW_OPS, + "Failed to signal %s: %s\n", + window->desc, strerror (errno)); + } + META_WINDOW_GET_CLASS (window)->kill (window); } diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index b74a8fac6..1b3e0909b 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -106,24 +106,6 @@ meta_window_wayland_kill (MetaWindow *window) { MetaWaylandSurface *surface = window->surface; struct wl_resource *resource = surface->resource; - pid_t pid; - uid_t uid; - gid_t gid; - - wl_client_get_credentials (wl_resource_get_client (resource), &pid, &uid, &gid); - if (pid > 0) - { - meta_topic (META_DEBUG_WINDOW_OPS, - "Killing %s with kill()\n", - window->desc); - - if (kill (pid, 9) == 0) - return; - - meta_topic (META_DEBUG_WINDOW_OPS, - "Failed to signal %s: %s\n", - window->desc, strerror (errno)); - } /* Send the client an unrecoverable error to kill the client. */ wl_resource_post_error (resource, diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index c8b9b0426..376d73c78 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -704,23 +704,6 @@ meta_window_x11_delete (MetaWindow *window, 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);