xprops: Make sure text_property_to_utf8() returns UTF8

Commit 840378ae68 changed the code to use XmbTextPropertyToTextList()
instead of gdk_text_property_to_utf8_list_for_display(), but didn't
take into account that the replacement returns text in the current
locale's encoding, while any callers (rightfully) expect UTF8.

Fix this by converting the text if necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/227
This commit is contained in:
Florian Müllner 2018-10-09 00:29:01 +02:00 committed by Jonas Ådahl
parent 62775d1913
commit 76abe87090

View File

@ -639,6 +639,7 @@ text_property_to_utf8 (Display *xdisplay,
{ {
char *ret = NULL; char *ret = NULL;
char **local_list = NULL; char **local_list = NULL;
const char *charset = NULL;
int count = 0; int count = 0;
int res; int res;
@ -649,7 +650,10 @@ text_property_to_utf8 (Display *xdisplay,
if (count == 0) if (count == 0)
goto out; goto out;
ret = g_strdup (local_list[0]); if (g_get_charset (&charset))
ret = g_strdup (local_list[0]);
else
ret = g_convert (local_list[0], -1, "UTF-8", charset, NULL, NULL, NULL);
out: out:
XFreeStringList (local_list); XFreeStringList (local_list);