From 141c249b8cd3b94a722acc8c0225b3cbf83e5042 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 23 Apr 2007 18:46:19 +0000 Subject: [PATCH] show the hostname of forwarded clients in the titlebar --- openbox/client.c | 29 +++++++++++++++++++++++++++-- openbox/client.h | 2 ++ openbox/prop.c | 1 + openbox/prop.h | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index dc4e52d2..2b9d5372 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -70,6 +70,7 @@ static void client_get_layer(ObClient *self); static void client_get_shaped(ObClient *self); static void client_get_mwm_hints(ObClient *self); static void client_get_gravity(ObClient *self); +static void client_get_client_machine(ObClient *self); static void client_change_allowed_actions(ObClient *self); static void client_change_state(ObClient *self); static void client_change_wm_state(ObClient *self); @@ -624,6 +625,7 @@ void client_unmanage(ObClient *self) g_free(self->name); g_free(self->class); g_free(self->role); + g_free(self->client_machine); g_free(self->sm_client_id); g_free(self); @@ -933,6 +935,7 @@ static void client_get_all(ObClient *self) (min/max sizes), so we're ready to set up the decorations/functions */ client_setup_decor_and_functions(self); + client_get_client_machine(self); client_update_title(self); client_update_class(self); client_update_sm_client_id(self); @@ -1641,6 +1644,7 @@ void client_update_wmhints(ObClient *self) void client_update_title(ObClient *self) { gchar *data = NULL; + gchar *visible = NULL; g_free(self->title); @@ -1660,8 +1664,14 @@ void client_update_title(ObClient *self) } } - PROP_SETS(self->window, net_wm_visible_name, data); - self->title = data; + if (self->client_machine) { + visible = g_strdup_printf("%s (%s)", data, self->client_machine); + g_free(data); + } else + visible = data; + + PROP_SETS(self->window, net_wm_visible_name, visible); + self->title = visible; if (self->frame) frame_adjust_title(self->frame); @@ -1860,6 +1870,21 @@ void client_update_user_time(ObClient *self) } } +static void client_get_client_machine(ObClient *self) +{ + gchar *data = NULL; + gchar localhost[128]; + + g_free(self->client_machine); + + if (PROP_GETS(self->window, wm_client_machine, locale, &data)) { + gethostname(localhost, 127); + localhost[127] = '\0'; + if (strcmp(localhost, data)) + self->client_machine = data; + } +} + static void client_change_wm_state(ObClient *self) { gulong state[2]; diff --git a/openbox/client.h b/openbox/client.h index 90c6c059..4ee4d5c3 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -116,6 +116,8 @@ struct _ObClient gchar *title; /*! Window title when iconified */ gchar *icon_title; + /*! Hostname of machine running client */ + gchar *client_machine; /*! The application that created the window */ gchar *name; diff --git a/openbox/prop.c b/openbox/prop.c index b3c65d31..655fd07b 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -48,6 +48,7 @@ void prop_startup() CREATE(wm_icon_name, "WM_ICON_NAME"); CREATE(wm_class, "WM_CLASS"); CREATE(wm_window_role, "WM_WINDOW_ROLE"); + CREATE(wm_client_machine, "WM_CLIENT_MACHINE"); CREATE(motif_wm_hints, "_MOTIF_WM_HINTS"); CREATE(sm_client_id, "SM_CLIENT_ID"); diff --git a/openbox/prop.h b/openbox/prop.h index 386b7a8a..1d3445f8 100644 --- a/openbox/prop.h +++ b/openbox/prop.h @@ -50,6 +50,7 @@ typedef struct Atoms { Atom wm_icon_name; Atom wm_class; Atom wm_window_role; + Atom wm_client_machine; Atom motif_wm_hints; /* SM atoms */ -- 2.45.2