diff --git a/src/core/delete.c b/src/core/delete.c index 3198625a5..e59101a82 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -179,36 +179,23 @@ meta_window_delete (MetaWindow *window, void meta_window_kill (MetaWindow *window) { - char buf[257]; - meta_topic (META_DEBUG_WINDOW_OPS, "Killing %s brutally\n", window->desc); - if (window->wm_client_machine != NULL && + if (!meta_window_is_remote (window) && window->net_wm_pid > 0) { - if (gethostname (buf, sizeof(buf)-1) == 0) - { - if (strcmp (buf, window->wm_client_machine) == 0) - { - meta_topic (META_DEBUG_WINDOW_OPS, - "Killing %s with kill()\n", - window->desc); + 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)); - } - } - else - { - meta_warning (_("Failed to get hostname: %s\n"), - strerror (errno)); - } + 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); diff --git a/src/core/display-private.h b/src/core/display-private.h index fa0676a2f..dc553384c 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -83,10 +83,11 @@ struct _MetaDisplay char *name; Display *xdisplay; + char *hostname; Window leader_window; Window timestamp_pinging_window; - + /* Pull in all the names of atoms as fields; we will intern them when the * class is constructed. */ diff --git a/src/core/display.c b/src/core/display.c index 4e6dc3f5a..ad9d13a30 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -429,6 +429,7 @@ meta_display_open (void) GSList *tmp; int i; guint32 timestamp; + char buf[257]; /* A list of all atom names, so that we can intern them in one go. */ char *atom_names[] = { @@ -463,6 +464,11 @@ meta_display_open (void) */ the_display->name = g_strdup (XDisplayName (NULL)); the_display->xdisplay = xdisplay; + if (gethostname (buf, sizeof(buf)-1) == 0) + { + buf[sizeof(buf)-1] = '\0'; + the_display->hostname = g_strdup (buf); + } the_display->error_trap_synced_at_last_pop = TRUE; the_display->error_traps = 0; the_display->error_trap_handler = NULL; diff --git a/src/core/window.c b/src/core/window.c index cf022e4bd..3c3877a07 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -9115,6 +9115,21 @@ meta_window_get_client_machine (MetaWindow *window) return window->wm_client_machine; } +/** + * meta_window_is_remote: + * @window: a #MetaWindow + * + * Returns: %TRUE if this window originates from a host + * different from the one running mutter. + */ +gboolean +meta_window_is_remote (MetaWindow *window) +{ + g_return_val_if_fail (META_IS_WINDOW (window), FALSE); + + return g_strcmp0 (window->wm_client_machine, window->display->hostname) != 0; +} + /** * meta_window_is_modal: * @window: a #MetaWindow diff --git a/src/include/window.h b/src/include/window.h index 367f2e29b..8cdcd18e8 100644 --- a/src/include/window.h +++ b/src/include/window.h @@ -140,6 +140,7 @@ guint meta_window_get_stable_sequence (MetaWindow *window); guint32 meta_window_get_user_time (MetaWindow *window); int meta_window_get_pid (MetaWindow *window); const char *meta_window_get_client_machine (MetaWindow *window); +gboolean meta_window_is_remote (MetaWindow *window); gboolean meta_window_is_modal (MetaWindow *window); const char *meta_window_get_mutter_hints (MetaWindow *window); #endif