diff options
Diffstat (limited to 'src/core/xprops.c')
-rw-r--r-- | src/core/xprops.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/core/xprops.c b/src/core/xprops.c index f9b4578a..a54e2185 100644 --- a/src/core/xprops.c +++ b/src/core/xprops.c @@ -264,6 +264,16 @@ cardinal_list_from_results (GetPropertyResults *results, *n_cardinals_p = results->n_items; results->prop = NULL; +#if GLIB_SIZEOF_LONG == 8 + /* Xlib sign-extends format=32 items, but we want them unsigned */ + { + int i; + + for (i = 0; i < *n_cardinals_p; i++) + (*cardinals_p)[i] = (*cardinals_p)[i] & 0xffffffff; + } +#endif + return TRUE; } @@ -608,6 +618,10 @@ cardinal_with_atom_type_from_results (GetPropertyResults *results, return FALSE; *cardinal_p = *(gulong*) results->prop; +#if GLIB_SIZEOF_LONG == 8 + /* Xlib sign-extends format=32 items, but we want them unsigned */ + *cardinal_p &= 0xffffffff; +#endif XFree (results->prop); results->prop = NULL; @@ -632,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) @@ -646,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); |