From 61427652626eadd7ed68257df8ec022250e103f7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 27 Feb 2023 14:12:19 +0100 Subject: [PATCH] frames: Minor refactor Move extraction of UTF8_STRING properties to a helper, as we'll want to use it for several properties. Part-of: --- src/frames/meta-frame.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/frames/meta-frame.c b/src/frames/meta-frame.c index 204e707e3..3d7be8c04 100644 --- a/src/frames/meta-frame.c +++ b/src/frames/meta-frame.c @@ -228,13 +228,14 @@ on_border_changed (GObject *object, meta_frame_update_extents (frame, border); } -static void -frame_sync_net_wm_name (GtkWindow *window, - Window client_window) +static char * +get_utf8_string_prop (GtkWindow *window, + Window client_window, + Atom prop) { MetaFrame *frame = META_FRAME (window); GdkDisplay *display; - char *title = NULL; + char *str = NULL; int format; Atom type; unsigned long nitems, bytes_after; @@ -245,21 +246,33 @@ frame_sync_net_wm_name (GtkWindow *window, if (XGetWindowProperty (gdk_x11_display_get_xdisplay (display), client_window, - frame->atom__NET_WM_NAME, + prop, 0, G_MAXLONG, False, gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), &type, &format, &nitems, &bytes_after, - (unsigned char **) &title) != Success) + (unsigned char **) &str) != Success) { gdk_x11_display_error_trap_pop_ignored (display); - return; + return NULL; } if (gdk_x11_display_error_trap_pop (display)) - return; + return NULL; + return str; +} + +static void +frame_sync_net_wm_name (GtkWindow *window, + Window client_window) +{ + MetaFrame *frame = META_FRAME (window); + char *title; + + title = get_utf8_string_prop (window, client_window, + frame->atom__NET_WM_NAME); gtk_window_set_title (window, title ? title : ""); g_free (title); }