From b4b73de038caffbca46e3f94e4ec056c16734f5c Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 20 Jul 2015 23:54:12 +0200 Subject: xprop: Don't use GDK for reading text properties --- src/core/xprops.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/core/xprops.c') diff --git a/src/core/xprops.c b/src/core/xprops.c index 82d28046..a54e2185 100644 --- a/src/core/xprops.c +++ b/src/core/xprops.c @@ -646,6 +646,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay *display, return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p); } +static char * +text_property_to_utf8 (Display *xdisplay, + const XTextProperty *prop) +{ + char *ret = NULL; + char **local_list = NULL; + int count = 0; + int res; + + res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count); + if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound) + goto out; + + if (count == 0) + goto out; + + ret = g_strdup (local_list[0]); + + out: + meta_XFree (local_list); + return ret; +} + static gboolean text_property_from_results (GetPropertyResults *results, char **utf8_str_p) @@ -660,8 +683,7 @@ text_property_from_results (GetPropertyResults *results, tp.format = results->format; tp.nitems = results->n_items; - *utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay, - &tp); + *utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp); if (tp.value != NULL) XFree (tp.value); -- cgit v1.2.1