summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2002-12-16 22:01:15 +0000
committerHavoc Pennington <hp@src.gnome.org>2002-12-16 22:01:15 +0000
commit1ad94dec1c63cbfb2b884da29a7b4267fa8e15bf (patch)
tree5d43804586372ef9ac16053437a51978dc2aedbb
parent995aef257735823c1334288f7e399686a0d0f450 (diff)
downloadmetacity-1ad94dec1c63cbfb2b884da29a7b4267fa8e15bf.tar.gz
use META_PROP_VALUE_STRING_AS_UTF8 so we convert old Latin-1 WM_NAME to
2002-12-16 Havoc Pennington <hp@pobox.com> * src/window-props.c: use META_PROP_VALUE_STRING_AS_UTF8 so we convert old Latin-1 WM_NAME to UTF-8 * src/xprops.h (enum): add META_PROP_VALUE_STRING_AS_UTF8 to get a latin1 string then convert.
-rw-r--r--ChangeLog8
-rw-r--r--src/window-props.c4
-rw-r--r--src/xprops.c43
-rw-r--r--src/xprops.h1
4 files changed, 52 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index bedf4bdc..f490ac0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2002-12-16 Havoc Pennington <hp@pobox.com>
+
+ * src/window-props.c: use META_PROP_VALUE_STRING_AS_UTF8 so
+ we convert old Latin-1 WM_NAME to UTF-8
+
+ * src/xprops.h (enum): add META_PROP_VALUE_STRING_AS_UTF8 to get a
+ latin1 string then convert.
+
2002-12-15 Havoc Pennington <hp@pobox.com>
* src/window.c (meta_window_new): get window name before anything
diff --git a/src/window-props.c b/src/window-props.c
index bcf63981..59bce1f4 100644
--- a/src/window-props.c
+++ b/src/window-props.c
@@ -228,7 +228,7 @@ init_wm_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
- value->type = META_PROP_VALUE_STRING;
+ value->type = META_PROP_VALUE_STRING_AS_UTF8;
value->atom = XA_WM_NAME;
}
@@ -302,7 +302,7 @@ init_wm_icon_name (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
- value->type = META_PROP_VALUE_STRING;
+ value->type = META_PROP_VALUE_STRING_AS_UTF8;
value->atom = XA_WM_ICON_NAME;
}
diff --git a/src/xprops.c b/src/xprops.c
index 88f7e17d..2c1f0316 100644
--- a/src/xprops.c
+++ b/src/xprops.c
@@ -897,6 +897,24 @@ get_task (MetaDisplay *display,
False, req_type);
}
+static char*
+latin1_to_utf8 (const char *text)
+{
+ GString *str;
+ const char *p;
+
+ str = g_string_new ("");
+
+ p = text;
+ while (*p)
+ {
+ g_string_append_unichar (str, *p);
+ ++p;
+ }
+
+ return g_string_free (str, FALSE);
+}
+
void
meta_prop_get_values (MetaDisplay *display,
Window xwindow,
@@ -936,6 +954,7 @@ meta_prop_get_values (MetaDisplay *display,
values[i].required_type = display->atom_utf8_string;
break;
case META_PROP_VALUE_STRING:
+ case META_PROP_VALUE_STRING_AS_UTF8:
values[i].required_type = XA_STRING;
break;
case META_PROP_VALUE_MOTIF_HINTS:
@@ -1047,6 +1066,27 @@ meta_prop_get_values (MetaDisplay *display,
&values[i].v.str))
values[i].type = META_PROP_VALUE_INVALID;
break;
+ case META_PROP_VALUE_STRING_AS_UTF8:
+ if (!latin1_string_from_results (&results,
+ &values[i].v.str))
+ values[i].type = META_PROP_VALUE_INVALID;
+ else
+ {
+ char *new_str;
+ char *xmalloc_new_str;
+
+ new_str = latin1_to_utf8 (values[i].v.str);
+ xmalloc_new_str = ag_Xmalloc (strlen (new_str) + 1);
+ if (xmalloc_new_str != NULL)
+ {
+ strcpy (xmalloc_new_str, new_str);
+ meta_XFree (values[i].v.str);
+ values[i].v.str = xmalloc_new_str;
+ }
+
+ g_free (new_str);
+ }
+ break;
case META_PROP_VALUE_MOTIF_HINTS:
if (!motif_hints_from_results (&results,
&values[i].v.motif_hints))
@@ -1119,9 +1159,8 @@ free_value (MetaPropValue *value)
case META_PROP_VALUE_INVALID:
break;
case META_PROP_VALUE_UTF8:
- meta_XFree (value->v.str);
- break;
case META_PROP_VALUE_STRING:
+ case META_PROP_VALUE_STRING_AS_UTF8:
meta_XFree (value->v.str);
break;
case META_PROP_VALUE_MOTIF_HINTS:
diff --git a/src/xprops.h b/src/xprops.h
index 24180ee6..fdf54615 100644
--- a/src/xprops.h
+++ b/src/xprops.h
@@ -134,6 +134,7 @@ typedef enum
META_PROP_VALUE_INVALID,
META_PROP_VALUE_UTF8,
META_PROP_VALUE_STRING,
+ META_PROP_VALUE_STRING_AS_UTF8,
META_PROP_VALUE_MOTIF_HINTS,
META_PROP_VALUE_CARDINAL,
META_PROP_VALUE_WINDOW,