summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavyd Madeley <davyd@fugro-fsi.com.au>2005-11-23 17:08:03 +0000
committerDavyd Madeley <davyd@src.gnome.org>2005-11-23 17:08:03 +0000
commit616d778f6b0429e0bcf935a870a66044a6239f2d (patch)
tree677deaf1f02144abab87f183c5a680b312fd07e1
parent6fa00967a59a123022f3f2e5d0d45bcc15f7ba6e (diff)
downloadmetacity-616d778f6b0429e0bcf935a870a66044a6239f2d.tar.gz
display hostname in titlebar for remote X clients. Closes bug #322202.
2005-11-24 Davyd Madeley <davyd@fugro-fsi.com.au> * src/window-props.c: display hostname in titlebar for remote X clients. Closes bug #322202.
-rw-r--r--ChangeLog5
-rw-r--r--src/window-props.c83
2 files changed, 58 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 221e8ede..b70fec6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-24 Davyd Madeley <davyd@fugro-fsi.com.au>
+
+ * src/window-props.c: display hostname in titlebar for remote X
+ clients. Closes bug #322202.
+
2005-11-22 Elijah Newren <newren@gmail.com>
* configure.in: post-release version bump to 2.13.5
diff --git a/src/window-props.c b/src/window-props.c
index a277ee46..7eff2ac3 100644
--- a/src/window-props.c
+++ b/src/window-props.c
@@ -26,6 +26,8 @@
#include "frame.h"
#include "group.h"
#include <X11/Xatom.h>
+#include <unistd.h>
+#include <string.h>
typedef void (* InitValueFunc) (MetaDisplay *display,
Atom property,
@@ -193,26 +195,60 @@ reload_net_wm_user_time (MetaWindow *window,
#define MAX_TITLE_LENGTH 512
-static void
-set_window_title (MetaWindow *window,
- const char *title)
+/**
+ * Called by set_window_title and set_icon_title to set the value of
+ * *target to title. It required and atom is set, it will update the
+ * appropriate property.
+ *
+ * Returns TRUE if a new title was set.
+ */
+static gboolean
+set_title_text (MetaWindow *window, const char *title, Atom atom, char **target)
{
- char *str;
+ char hostname[HOST_NAME_MAX + 1];
+ gboolean modified = FALSE;
- g_free (window->title);
+ if (!target)
+ return FALSE;
- if (title == NULL)
- window->title = g_strdup ("");
- else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) <= MAX_TITLE_LENGTH)
- window->title = g_strdup (title);
- else
+ g_free (*target);
+
+ if (!title)
+ *target = g_strdup ("");
+ else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) > MAX_TITLE_LENGTH)
{
- window->title = meta_g_utf8_strndup (title, MAX_TITLE_LENGTH);
- meta_prop_set_utf8_string_hint (window->display,
- window->xwindow,
- window->display->atom_net_wm_visible_name,
- window->title);
+ *target = meta_g_utf8_strndup (title, MAX_TITLE_LENGTH);
+ modified = TRUE;
+ }
+ /* if WM_CLIENT_MACHINE indicates this machine is on a remote host
+ * lets place that hostname in the title */
+ else if (window->wm_client_machine &&
+ !gethostname (hostname, HOST_NAME_MAX + 1) &&
+ strcmp (hostname, window->wm_client_machine))
+ {
+ *target = g_strdup_printf ("%s (on %s)",
+ title, window->wm_client_machine);
+ modified = TRUE;
}
+ else
+ *target = g_strdup (title);
+
+ if (modified && atom != None)
+ meta_prop_set_utf8_string_hint (window->display,
+ window->xwindow,
+ atom, *target);
+
+ return modified;
+}
+
+static void
+set_window_title (MetaWindow *window,
+ const char *title)
+{
+ char *str;
+
+ set_title_text (window, title, window->display->atom_net_wm_visible_name,
+ &window->title);
/* strndup is a hack since GNU libc has broken %.10s */
str = g_strndup (window->title, 10);
@@ -292,21 +328,8 @@ static void
set_icon_title (MetaWindow *window,
const char *title)
{
- g_free (window->icon_name);
-
- if (title == NULL)
- window->icon_name = g_strdup ("");
- else if (g_utf8_strlen (title, MAX_TITLE_LENGTH + 1) <= MAX_TITLE_LENGTH)
- window->icon_name = g_strdup (title);
- else
- {
- window->icon_name = meta_g_utf8_strndup (title, MAX_TITLE_LENGTH);
- meta_prop_set_utf8_string_hint (window->display,
- window->xwindow,
- window->display->atom_net_wm_visible_icon_name,
- window->icon_name);
- }
-
+ set_title_text (window, title, window->display->atom_net_wm_visible_icon_name,
+ &window->icon_name);
}
static void