Add meta_window_is_remote
It's useful for plugins to be able to easily detect whether or not a window is from a remote host. Also, make use of this in the window delete codepath, instead of looking up the hostname each time. https://bugzilla.gnome.org/show_bug.cgi?id=620585
This commit is contained in:
parent
343474a570
commit
3a73f6b8ec
@ -179,36 +179,23 @@ meta_window_delete (MetaWindow *window,
|
|||||||
void
|
void
|
||||||
meta_window_kill (MetaWindow *window)
|
meta_window_kill (MetaWindow *window)
|
||||||
{
|
{
|
||||||
char buf[257];
|
|
||||||
|
|
||||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
"Killing %s brutally\n",
|
"Killing %s brutally\n",
|
||||||
window->desc);
|
window->desc);
|
||||||
|
|
||||||
if (window->wm_client_machine != NULL &&
|
if (!meta_window_is_remote (window) &&
|
||||||
window->net_wm_pid > 0)
|
window->net_wm_pid > 0)
|
||||||
{
|
{
|
||||||
if (gethostname (buf, sizeof(buf)-1) == 0)
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
{
|
"Killing %s with kill()\n",
|
||||||
if (strcmp (buf, window->wm_client_machine) == 0)
|
window->desc);
|
||||||
{
|
|
||||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
|
||||||
"Killing %s with kill()\n",
|
|
||||||
window->desc);
|
|
||||||
|
|
||||||
if (kill (window->net_wm_pid, 9) < 0)
|
if (kill (window->net_wm_pid, 9) < 0)
|
||||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
"Failed to signal %s: %s\n",
|
"Failed to signal %s: %s\n",
|
||||||
window->desc, strerror (errno));
|
window->desc, strerror (errno));
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
meta_warning (_("Failed to get hostname: %s\n"),
|
|
||||||
strerror (errno));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
"Disconnecting %s with XKillClient()\n",
|
"Disconnecting %s with XKillClient()\n",
|
||||||
window->desc);
|
window->desc);
|
||||||
|
@ -83,10 +83,11 @@ struct _MetaDisplay
|
|||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
char *hostname;
|
||||||
|
|
||||||
Window leader_window;
|
Window leader_window;
|
||||||
Window timestamp_pinging_window;
|
Window timestamp_pinging_window;
|
||||||
|
|
||||||
/* Pull in all the names of atoms as fields; we will intern them when the
|
/* Pull in all the names of atoms as fields; we will intern them when the
|
||||||
* class is constructed.
|
* class is constructed.
|
||||||
*/
|
*/
|
||||||
|
@ -429,6 +429,7 @@ meta_display_open (void)
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int i;
|
int i;
|
||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
|
char buf[257];
|
||||||
|
|
||||||
/* A list of all atom names, so that we can intern them in one go. */
|
/* A list of all atom names, so that we can intern them in one go. */
|
||||||
char *atom_names[] = {
|
char *atom_names[] = {
|
||||||
@ -463,6 +464,11 @@ meta_display_open (void)
|
|||||||
*/
|
*/
|
||||||
the_display->name = g_strdup (XDisplayName (NULL));
|
the_display->name = g_strdup (XDisplayName (NULL));
|
||||||
the_display->xdisplay = xdisplay;
|
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_trap_synced_at_last_pop = TRUE;
|
||||||
the_display->error_traps = 0;
|
the_display->error_traps = 0;
|
||||||
the_display->error_trap_handler = NULL;
|
the_display->error_trap_handler = NULL;
|
||||||
|
@ -9115,6 +9115,21 @@ meta_window_get_client_machine (MetaWindow *window)
|
|||||||
return window->wm_client_machine;
|
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:
|
* meta_window_is_modal:
|
||||||
* @window: a #MetaWindow
|
* @window: a #MetaWindow
|
||||||
|
@ -140,6 +140,7 @@ guint meta_window_get_stable_sequence (MetaWindow *window);
|
|||||||
guint32 meta_window_get_user_time (MetaWindow *window);
|
guint32 meta_window_get_user_time (MetaWindow *window);
|
||||||
int meta_window_get_pid (MetaWindow *window);
|
int meta_window_get_pid (MetaWindow *window);
|
||||||
const char *meta_window_get_client_machine (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);
|
gboolean meta_window_is_modal (MetaWindow *window);
|
||||||
const char *meta_window_get_mutter_hints (MetaWindow *window);
|
const char *meta_window_get_mutter_hints (MetaWindow *window);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user