From 48a36356ddd0892202b4cf6ed8100827647681cf Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 18 Mar 2014 21:19:51 -0400 Subject: [PATCH] window: Make window->desc a bit clearer And remove the hack for the "broken GNU libc". It works fine on my system here. --- src/core/window.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 68d9c5140..6bc821acc 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -742,6 +742,17 @@ sync_client_window_mapped (MetaWindow *window) meta_error_trap_pop (window->display); } +static void +meta_window_update_desc (MetaWindow *window) +{ + g_clear_pointer (&window->desc, g_free); + + if (window->title) + window->desc = g_strdup_printf ("0x%lx (%.10s)", window->xwindow, window->title); + else + window->desc = g_strdup_printf ("0x%lx", window->xwindow); +} + MetaWindow * _meta_window_shared_new (MetaDisplay *display, MetaScreen *screen, @@ -797,7 +808,7 @@ _meta_window_shared_new (MetaDisplay *display, window->screen = screen; - window->desc = g_strdup_printf ("0x%lx", window->xwindow); + meta_window_update_desc (window); window->override_redirect = attrs->override_redirect; @@ -9925,22 +9936,16 @@ void meta_window_set_title (MetaWindow *window, const char *title) { - char *str; - g_free (window->title); window->title = g_strdup (title); - /* strndup is a hack since GNU libc has broken %.10s */ - str = g_strndup (window->title, 10); - g_free (window->desc); - window->desc = g_strdup_printf ("0x%lx (%s)", window->xwindow, str); - g_free (str); - if (window->frame) meta_ui_set_frame_title (window->screen->ui, window->frame->xwindow, window->title); + meta_window_update_desc (window); + g_object_notify (G_OBJECT (window), "title"); }