window: fix meta_window_is_remote across hostname changes

meta_window_is_remote compares a cached copy of the system hostname
with the hostname of the client window
(as presented by the WM_CLIENT_MACHINE property).

Of course, the system hostname can change at any time, so caching
it is wrong. Also, the WM_CLIENT_MACHINE property won't necessarily
change when the system hostname changes, so comparing it with the
new system hostname is wrong, too.

This commit makes the code call gethostname() at the time
WM_CLIENT_MACHINE is set, check whether it's remote then, and cache
that value, rather than comparing potentially out of sync hostnames
later.

https://bugzilla.gnome.org/show_bug.cgi?id=688716
This commit is contained in:
Ray Strode
2013-02-20 15:17:21 -05:00
parent 64544fa0ed
commit 2cafb8be2d
5 changed files with 24 additions and 15 deletions

View File

@@ -37,6 +37,7 @@
*/
#define _GNU_SOURCE
#define _SVID_SOURCE /* for gethostname() */
#include <config.h>
#include "window-props.h"
@@ -48,6 +49,11 @@
#include <unistd.h>
#include <string.h>
#ifndef HOST_NAME_MAX
/* Solaris headers apparently don't define this so do so manually; #326745 */
#define HOST_NAME_MAX 255
#endif
typedef void (* ReloadValueFunc) (MetaWindow *window,
MetaPropValue *value,
gboolean initial);
@@ -195,6 +201,19 @@ reload_wm_client_machine (MetaWindow *window,
meta_verbose ("Window has client machine \"%s\"\n",
window->wm_client_machine ? window->wm_client_machine : "unset");
if (window->wm_client_machine == NULL)
{
window->is_remote = FALSE;
}
else
{
char hostname[HOST_NAME_MAX + 1] = "";
gethostname (hostname, HOST_NAME_MAX + 1);
window->is_remote = g_strcmp0 (window->wm_client_machine, hostname) != 0;
}
}
static void