diff options
-rw-r--r-- | src/client.c | 5 | ||||
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/events.c | 17 | ||||
-rw-r--r-- | src/frame.c | 28 | ||||
-rw-r--r-- | src/hints.c | 109 |
5 files changed, 72 insertions, 88 deletions
diff --git a/src/client.c b/src/client.c index b0179b746..dff86f376 100644 --- a/src/client.c +++ b/src/client.c @@ -1180,10 +1180,6 @@ clientFree (Client * c) { g_free (c->name); } - if (c->client_machine) - { - g_free (c->client_machine); - } #ifdef HAVE_LIBSTARTUP_NOTIFICATION if (c->startup_id) { @@ -1550,7 +1546,6 @@ clientFrame (DisplayInfo *display_info, Window w, gboolean recapture) c->screen_info = screen_info; c->serial = screen_info->client_serial++; - getClientMachine (display_info, c->window, &c->client_machine); getWindowName (display_info, c->window, &c->name); TRACE ("name \"%s\"", c->name); getTransientFor (display_info, screen_info->xroot, c->window, &c->transient_for); diff --git a/src/client.h b/src/client.h index 365023862..bb656550a 100644 --- a/src/client.h +++ b/src/client.h @@ -254,7 +254,6 @@ struct _Client int button_pressed[BUTTON_COUNT]; int struts[12]; gchar *name; - gchar *client_machine; GTimeVal last_op_time; Time user_time; unsigned long flags; diff --git a/src/events.c b/src/events.c index 408aee225..865a5dd3c 100644 --- a/src/events.c +++ b/src/events.c @@ -1710,9 +1710,11 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev) TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NORMAL_HINTS notify", c->name, c->window); clientGetWMNormalHints (c, TRUE); } - else if ((ev->atom == XA_WM_NAME) || (ev->atom == display_info->atoms[NET_WM_NAME])) + else if ((ev->atom == XA_WM_NAME) || + (ev->atom == display_info->atoms[NET_WM_NAME]) || + (ev->atom == display_info->atoms[WM_CLIENT_MACHINE])) { - TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NAME notify", c->name, c->window); + TRACE ("client \"%s\" (0x%lx) has received a XA_WM_NAME/NET_WM_NAME/WM_CLIENT_MACHINE notify", c->name, c->window); if (c->name) { g_free (c->name); @@ -1721,17 +1723,6 @@ handlePropertyNotify (DisplayInfo *display_info, XPropertyEvent * ev) FLAG_SET (c->flags, CLIENT_FLAG_NAME_CHANGED); frameDraw (c, TRUE, FALSE); } - else if (ev->atom == display_info->atoms[WM_CLIENT_MACHINE]) - { - TRACE ("client \"%s\" (0x%lx) has received a WM_CLIENT_MACHINE notify", c->name, c->window); - if (c->client_machine) - { - g_free (c->client_machine); - } - getClientMachine (display_info, c->window, &c->client_machine); - FLAG_SET (c->flags, CLIENT_FLAG_NAME_CHANGED); - frameDraw (c, TRUE, FALSE); - } else if (ev->atom == display_info->atoms[MOTIF_WM_HINTS]) { TRACE ("client \"%s\" (0x%lx) has received a motif_wm_hints notify", c->name, c->window); diff --git a/src/frame.c b/src/frame.c index f5ce48090..83f9e65de 100644 --- a/src/frame.c +++ b/src/frame.c @@ -191,28 +191,6 @@ frameHeight (Client * c) return c->height; } -static gchar* -frameGetTitle (Client * c) -{ - ScreenInfo *screen_info = NULL; - DisplayInfo *display_info = NULL; - gchar *title = NULL; - - screen_info = c->screen_info; - display_info = screen_info->display_info; - - if ((display_info->hostname) && (c->client_machine) && (g_strcasecmp (display_info->hostname, c->client_machine))) - { - title = g_strdup_printf (_("%s (on %s)"), c->name, c->client_machine); - } - else - { - title = g_strdup (c->name); - } - - return title; -} - static void frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * pm) { @@ -225,7 +203,6 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * PangoRectangle logical_rect; int width, x = 0, tp = 0, w1 = 0, w2, w3, w4, w5, temp; int voffset = 0; - gchar *title; TRACE ("entering frameCreateTitlePixmap"); @@ -275,10 +252,9 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * w2 = screen_info->title[TITLE_2][state].width; w4 = screen_info->title[TITLE_4][state].width; - title = frameGetTitle (c); - layout = gtk_widget_create_pango_layout (myScreenGetGtkWidget (screen_info), title); + layout = gtk_widget_create_pango_layout (myScreenGetGtkWidget (screen_info), c->name); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); - g_free (title); + if (screen_info->params->full_width_title) { w1 = left; diff --git a/src/hints.c b/src/hints.c index 38cc5056f..ed49c7654 100644 --- a/src/hints.c +++ b/src/hints.c @@ -49,6 +49,40 @@ check_type_and_format (int expected_format, Atom expected_type, int n_items, int return FALSE; } +static gchar * +internal_utf8_strndup (const gchar *src, gssize max_len) +{ + const gchar *s = src; + + if (max_len <= 0) + return g_strdup (src); + + while (max_len && *s) + { + s = g_utf8_next_char (s); + max_len--; + } + + return g_strndup (src, s - src); +} + +static gchar* +create_name_with_host (DisplayInfo *display_info, const gchar *name, const gchar *hostname) +{ + gchar *title = NULL; + + if ((display_info->hostname) && (g_strcasecmp (display_info->hostname, hostname))) + { + title = g_strdup_printf (_("%s (on %s)"), name, hostname); + } + else + { + title = g_strdup (name); + } + + return title; +} + unsigned long getWMState (DisplayInfo *display_info, Window w) { @@ -581,23 +615,6 @@ getTransientFor (DisplayInfo *display_info, Window root, Window w, Window * tran TRACE ("Window (0x%lx) is transient for (0x%lx)", w, *transient_for); } -static gchar * -internal_utf8_strndup (const gchar *src, gssize max_len) -{ - const gchar *s = src; - - if (max_len <= 0) - return g_strdup (src); - - while (max_len && *s) - { - s = g_utf8_next_char (s); - max_len--; - } - - return g_strndup (src, s - src); -} - static char * text_property_to_utf8 (DisplayInfo *display_info, const XTextProperty * prop) { @@ -783,56 +800,62 @@ getUTF8StringList (DisplayInfo *display_info, Window w, int atom_id, gchar ***st } gboolean -getWindowName (DisplayInfo *display_info, Window w, gchar **name) +getClientMachine (DisplayInfo *display_info, Window w, gchar **machine) { char *str; - int len; + gboolean status = FALSE; - TRACE ("entering getWindowName"); + TRACE ("entering getClientMachine"); - g_return_val_if_fail (name != NULL, FALSE); - *name = NULL; + g_return_val_if_fail (machine != NULL, FALSE); + *machine = NULL; g_return_val_if_fail (w != None, FALSE); - if (getUTF8StringData (display_info, w, NET_WM_NAME, &str, &len)) - { - *name = internal_utf8_strndup (str, MAX_STR_LENGTH); - XFree (str); - return TRUE; - } - str = get_text_property (display_info, w, XA_WM_NAME); + str = get_text_property (display_info, w, display_info->atoms[WM_CLIENT_MACHINE]); if (str) { - *name = internal_utf8_strndup (str, MAX_STR_LENGTH); + *machine = g_strndup (str, MAX_STR_LENGTH); XFree (str); - return TRUE; + status = TRUE; } else { - *name = g_strdup (""); + *machine = g_strdup (""); } - return FALSE; + return status; } gboolean -getClientMachine (DisplayInfo *display_info, Window w, gchar **machine) +getWindowName (DisplayInfo *display_info, Window w, gchar **title) { char *str; + int len; + gchar *machine; + gchar *name; + gboolean status = FALSE; + + TRACE ("entering getWindowName"); - TRACE ("entering getClientMachine"); - - g_return_val_if_fail (machine != NULL, FALSE); - *machine = NULL; + g_return_val_if_fail (title != NULL, FALSE); + *title = NULL; g_return_val_if_fail (w != None, FALSE); - str = get_text_property (display_info, w, display_info->atoms[WM_CLIENT_MACHINE]); - if (str) + getClientMachine (display_info, w, &machine); + if (getUTF8StringData (display_info, w, NET_WM_NAME, &str, &len) || + (str = get_text_property (display_info, w, XA_WM_NAME))) { - *machine = g_strndup (str, MAX_STR_LENGTH); + name = internal_utf8_strndup (str, MAX_STR_LENGTH); + *title = create_name_with_host (display_info, name, machine); + g_free (name); XFree (str); - return TRUE; + status = TRUE; } - return FALSE; + else + { + *title = g_strdup (""); + } + g_free (machine); + return status; } gboolean |