From: Dana Jansens Date: Thu, 16 Sep 2010 18:52:49 +0000 (-0400) Subject: Handle STRING and COMPOUND_TEXT type text properties. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=5d5714f01e1a7140847f6e7f2922d457f6bbe66a;p=chaz%2Fopenbox Handle STRING and COMPOUND_TEXT type text properties. STRING should be latin1 text (plus TAB and LF) COMPOUND_TEXT should be encoded in the current locale. --- diff --git a/obt/prop.c b/obt/prop.c index bef9c999..d5af6a0b 100644 --- a/obt/prop.c +++ b/obt/prop.c @@ -45,7 +45,8 @@ void obt_prop_startup(void) CREATE(PIXMAP); CREATE(ATOM); CREATE(STRING); - CREATE_NAME(UTF8, "UTF8_STRING"); + CREATE(COMPOUND_TEXT); + CREATE(UTF8_STRING); CREATE(MANAGER); @@ -283,128 +284,236 @@ static gboolean get_all(Window win, Atom prop, Atom type, gint size, return ret; } -static gboolean get_stringlist(Window win, Atom prop, gchar ***list, gint *nstr) +/*! Get a text property from a window, and fill out the XTextProperty with it. + @param win The window to read the property from. + @param prop The atom of the property to read off the window. + @param tprop The XTextProperty to fill out. + @param type 0 to get text of any type, or a value from + ObtPropTextType to restrict the value to a specific type. + @return TRUE if the text was read and validated against the @type, and FALSE + otherwise. +*/ +static gboolean get_text_property(Window win, Atom prop, + XTextProperty *tprop, ObtPropTextType type) { - XTextProperty tprop; - gboolean ret = FALSE; - - if (XGetTextProperty(obt_display, win, &tprop, prop) && tprop.nitems) { - if (XTextPropertyToStringList(&tprop, list, nstr)) - ret = TRUE; - XFree(tprop.value); + if (!(XGetTextProperty(obt_display, win, tprop, prop) && tprop->nitems)) + return FALSE; + if (!type) + return TRUE; /* no type checking */ + switch (type) { + case OBT_PROP_TEXT_STRING: + case OBT_PROP_TEXT_STRING_XPCS: + case OBT_PROP_TEXT_STRING_NO_CC: + return tprop->encoding == OBT_PROP_ATOM(STRING); + case OBT_PROP_TEXT_COMPOUND_TEXT: + return tprop->encoding == OBT_PROP_ATOM(COMPOUND_TEXT); + case OBT_PROP_TEXT_UTF8_STRING: + return tprop->encoding == OBT_PROP_ATOM(UTF8_STRING); + default: + g_assert_not_reached(); } - return ret; -} - -gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret) -{ - return get_prealloc(win, prop, type, 32, (guchar*)ret, 1); } -gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret, - guint *nret) +/*! Returns one or more UTF-8 encoded strings from the text property. + @param tprop The XTextProperty to convert into UTF-8 string(s). + @param type The type which specifies the format that the text must meet, or + 0 to allow any valid characters that can be converted to UTF-8 through. + @param max The maximum number of strings to return. -1 to return them all. + @return If max is 1, then this returns a gchar* with the single string. + Otherwise, this returns a gchar** of no more than max strings (or all + strings read, if max is negative). If an error occurs, NULL is returned. + */ +static void* convert_text_property(XTextProperty *tprop, + ObtPropTextType type, gint max) { - return get_all(win, prop, type, 32, (guchar**)ret, nret); -} - -gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret) -{ - gchar **list; - gint nstr; - gchar *s; - - if (get_stringlist(win, prop, &list, &nstr) && nstr) { - s = g_locale_to_utf8(list[0], -1, NULL, NULL, NULL); - XFreeStringList(list); - if (s) { - *ret = s; - return TRUE; + enum { + LATIN1, + UTF8, + LOCALE + } encoding; + const gboolean return_single = (max == 1); + gboolean ok = FALSE; + gchar **strlist = NULL; + gchar *single[1] = { NULL }; + gchar **retlist = single; /* single is used when max == 1 */ + gint i, n_strs; + + /* Read each string in the text property and store a pointer to it in + retlist. These pointers point into the X data structures directly. + + Then we will convert them to UTF-8, and replace the retlist pointer with + a new one. + */ + if (tprop->encoding == OBT_PROP_ATOM(COMPOUND_TEXT)) + { + encoding = LOCALE; + ok = (XmbTextPropertyToTextList( + obt_display, tprop, &strlist, &n_strs) == Success); + if (ok) { + if (max >= 0) + n_strs = MIN(max, n_strs); + if (!return_single) + retlist = g_new0(gchar*, n_strs+1); + if (retlist) + for (i = 0; i < n_strs; ++i) + retlist[i] = strlist[i]; } } - return FALSE; -} - -gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret) -{ - GSList *strs = NULL, *it; - gchar *raw, *p; - guint num, i, count = 0; - - if (get_all(win, prop, OBT_PROP_ATOM(STRING), 8, - (guchar**)&raw, &num)) + else if (tprop->encoding == OBT_PROP_ATOM(UTF8_STRING) || + tprop->encoding == OBT_PROP_ATOM(STRING)) { - p = raw; - while (p < raw + num) { - ++count; - strs = g_slist_append(strs, p); + gchar *p; /* iterator */ + + if (tprop->encoding == OBT_PROP_ATOM(STRING)) + encoding = LATIN1; + else + encoding = UTF8; + ok = TRUE; + + /* First, count the number of strings. Then make a structure for them + and copy pointers to them into it. */ + p = (gchar*)tprop->value; + n_strs = 0; + while (p < (gchar*)tprop->value + tprop->nitems) { p += strlen(p) + 1; /* next string */ + ++n_strs; } - *ret = g_new0(gchar*, count + 1); - (*ret)[count] = NULL; /* null terminated list */ + if (max >= 0) + n_strs = MIN(max, n_strs); + if (!return_single) + retlist = g_new0(gchar*, n_strs+1); + if (retlist) { + p = (gchar*)tprop->value; + for (i = 0; i < n_strs; ++i) { + retlist[i] = p; + p += strlen(p) + 1; /* next string */ + } + } + } + + if (!(ok && retlist)) { + if (strlist) XFreeStringList(strlist); + return NULL; + } + + /* convert each element in retlist to UTF-8, and replace it. */ + for (i = 0; i < n_strs; ++i) { + if (encoding == UTF8) { + const gchar *end; /* the first byte past the valid data */ - for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) { - (*ret)[i] = g_locale_to_utf8(it->data, -1, NULL, NULL, NULL); - /* make sure translation did not fail */ - if (!(*ret)[i]) - (*ret)[i] = g_strdup(""); + g_utf8_validate(retlist[i], -1, &end); + retlist[i] = g_strndup(retlist[i], end-retlist[i]); + } + else if (encoding == LOCALE) { + gsize nvalid; /* the number of valid bytes at the front of the + string */ + gchar *utf; /* the string converted into utf8 */ + + utf = g_locale_to_utf8(retlist[i], -1, &nvalid, NULL, NULL); + if (!utf) + utf = g_locale_to_utf8(retlist[i], nvalid, NULL, NULL, NULL); + g_assert(utf); + retlist[i] = utf; + } + else { /* encoding == LATIN1 */ + gsize nvalid; /* the number of valid bytes at the front of the + string */ + gchar *utf; /* the string converted into utf8 */ + gchar *p; /* iterator */ + + /* look for invalid characters */ + for (p = retlist[i], nvalid = 0; *p; ++p, ++nvalid) { + /* The only valid control characters are TAB(HT)=9 and + NEWLINE(LF)=10. + This is defined in ICCCM section 2: + http://tronche.com/gui/x/icccm/sec-2.html. + See a definition of the latin1 codepage here: + http://en.wikipedia.org/wiki/ISO/IEC_8859-1. + The above page includes control characters in the table, + which we must explicitly exclude, as the g_convert function + will happily take them. + */ + const register guchar c = (guchar)*p; /* unsigned value at p */ + if ((c < 32 && c != 9 && c != 10) || (c >= 127 && c <= 160)) + break; /* found a control character that isn't allowed */ + + if (type == OBT_PROP_TEXT_STRING_NO_CC && c < 32) + break; /* absolutely no control characters are allowed */ + + if (type == OBT_PROP_TEXT_STRING_XPCS) { + const gboolean valid = ( + (c >= 32 && c < 128) || c == 9 || c == 10); + if (!valid) + break; /* strict whitelisting for XPCS */ + } + } + /* look for invalid latin1 characters */ + utf = g_convert(retlist[i], nvalid, "utf-8", "iso-8859-1", + &nvalid, NULL, NULL); + if (!utf) + utf = g_convert(retlist[i], nvalid, "utf-8", "iso-8859-1", + NULL, NULL, NULL); + g_assert(utf); + retlist[i] = utf; } - g_free(raw); - g_slist_free(strs); - return TRUE; } - return FALSE; + + if (strlist) XFreeStringList(strlist); + if (return_single) + return retlist[0]; + else + return retlist; } -gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret) +gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret) { - gchar *raw; + return get_prealloc(win, prop, type, 32, (guchar*)ret, 1); +} + +gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret, + guint *nret) +{ + return get_all(win, prop, type, 32, (guchar**)ret, nret); +} + +gboolean obt_prop_get_text(Window win, Atom prop, ObtPropTextType type, + gchar **ret_string) +{ + XTextProperty tprop; gchar *str; - guint num; + gboolean ret = FALSE; - if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8, - (guchar**)&raw, &num)) - { - str = g_strndup(raw, num); /* grab the first string from the list */ - g_free(raw); - if (g_utf8_validate(str, -1, NULL)) { - *ret = str; - return TRUE; + if (get_text_property(win, prop, &tprop, type)) { + str = (gchar*)convert_text_property(&tprop, type, 1); + + if (str) { + *ret_string = str; + ret = TRUE; } - g_free(str); } - return FALSE; + XFree(tprop.value); + return ret; } -gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret) +gboolean obt_prop_get_array_text(Window win, Atom prop, + ObtPropTextType type, + gchar ***ret_strings) { - GSList *strs = NULL, *it; - gchar *raw, *p; - guint num, i, count = 0; - - if (get_all(win, prop, OBT_PROP_ATOM(UTF8), 8, - (guchar**)&raw, &num)) - { - p = raw; - while (p < raw + num) { - ++count; - strs = g_slist_append(strs, p); - p += strlen(p) + 1; /* next string */ - } + XTextProperty tprop; + gchar **strs; + gboolean ret = FALSE; - *ret = g_new0(gchar*, count + 1); + if (get_text_property(win, prop, &tprop, type)) { + strs = (gchar**)convert_text_property(&tprop, type, -1); - for (i = 0, it = strs; it; ++i, it = g_slist_next(it)) { - if (g_utf8_validate(it->data, -1, NULL)) - (*ret)[i] = g_strdup(it->data); - else - (*ret)[i] = g_strdup(""); + if (strs) { + *ret_strings = strs; + ret = TRUE; } - g_free(raw); - g_slist_free(strs); - return TRUE; } - return FALSE; + XFree(tprop.value); + return ret; } void obt_prop_set32(Window win, Atom prop, Atom type, gulong val) @@ -420,45 +529,13 @@ void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val, (guchar*)val, num); } -void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val) -{ - gchar const *s[2] = { val, NULL }; - obt_prop_set_strings_locale(win, prop, s); -} - -void obt_prop_set_strings_locale(Window win, Atom prop, - const gchar *const *strs) -{ - gint i, count; - gchar **lstrs; - XTextProperty tprop; - - /* count the strings in strs, and convert them to the locale format */ - for (count = 0; strs[count]; ++count); - lstrs = g_new0(char*, count); - for (i = 0; i < count; ++i) { - lstrs[i] = g_locale_from_utf8(strs[i], -1, NULL, NULL, NULL); - if (!lstrs[i]) { - lstrs[i] = g_strdup(""); /* make it an empty string */ - g_warning("Unable to translate string '%s' from UTF8 to locale " - "format", strs[i]); - } - } - - - XStringListToTextProperty(lstrs, count, &tprop); - XSetTextProperty(obt_display, win, &tprop, prop); - XFree(tprop.value); -} - -void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val) +void obt_prop_set_text(Window win, Atom prop, const gchar *val) { - XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8), 8, + XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8_STRING), 8, PropModeReplace, (const guchar*)val, strlen(val)); } -void obt_prop_set_strings_utf8(Window win, Atom prop, - const gchar *const *strs) +void obt_prop_set_array_text(Window win, Atom prop, const gchar *const *strs) { GString *str; gchar const *const *s; @@ -468,7 +545,7 @@ void obt_prop_set_strings_utf8(Window win, Atom prop, str = g_string_append(str, *s); str = g_string_append_c(str, '\0'); } - XChangeProperty(obt_display, win, prop, obt_prop_atom(OBT_PROP_UTF8), 8, + XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8_STRING), 8, PropModeReplace, (guchar*)str->str, str->len); g_string_free(str, TRUE); } diff --git a/obt/prop.h b/obt/prop.h index 7ccc218e..9c4ace33 100644 --- a/obt/prop.h +++ b/obt/prop.h @@ -28,11 +28,13 @@ G_BEGIN_DECLS typedef enum { /* types */ OBT_PROP_CARDINAL, /*!< The atom which represents the Cardinal data type */ - OBT_PROP_WINDOW, /*!< The atom which represents window ids */ - OBT_PROP_PIXMAP, /*!< The atom which represents pixmap ids */ - OBT_PROP_ATOM, /*!< The atom which represents atom values */ - OBT_PROP_STRING, /*!< The atom which represents ascii strings */ - OBT_PROP_UTF8, /*!< The atom which represents utf8-encoded strings */ + OBT_PROP_WINDOW, /*!< The atom which represents window ids */ + OBT_PROP_PIXMAP, /*!< The atom which represents pixmap ids */ + OBT_PROP_ATOM, /*!< The atom which represents atom values */ + OBT_PROP_STRING, /*!< The atom which represents latin1 strings */ + OBT_PROP_COMPOUND_TEXT, /*!< The atom which represents locale-encoded + strings */ + OBT_PROP_UTF8_STRING, /*!< The atom which represents utf8-encoded strings*/ /* selection stuff */ OBT_PROP_MANAGER, @@ -223,23 +225,39 @@ typedef enum { Atom obt_prop_atom(ObtPropAtom a); +typedef enum { + /*! STRING is latin1 encoded. It cannot contain control characters except + for tab and line-feed. */ + OBT_PROP_TEXT_STRING = 1, + /*! STRING text restricted to characters in the X Portable Character + Set, which is a subset of latin1. + http://static.cray-cyber.org/Documentation/NEC_SX_R10_1/G1AE02E/CHAP1.HTML + */ + OBT_PROP_TEXT_STRING_XPCS = 2, + /*! STRING text restricted to not allow any control characters to be + present. */ + OBT_PROP_TEXT_STRING_NO_CC = 3, + /* COMPOUND_TEXT is encoded in the current locale setting. */ + OBT_PROP_TEXT_COMPOUND_TEXT = 4, + /* UTF8_STRING is encoded as utf-8. */ + OBT_PROP_TEXT_UTF8_STRING = 5, +} ObtPropTextType; + gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret); gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret, guint *nret); -gboolean obt_prop_get_string_locale(Window win, Atom prop, gchar **ret); -gboolean obt_prop_get_string_utf8(Window win, Atom prop, gchar **ret); -gboolean obt_prop_get_strings_locale(Window win, Atom prop, gchar ***ret); -gboolean obt_prop_get_strings_utf8(Window win, Atom prop, gchar ***ret); + +gboolean obt_prop_get_text(Window win, Atom prop, ObtPropTextType type, + gchar **ret); +gboolean obt_prop_get_array_text(Window win, Atom prop, + ObtPropTextType type, + gchar ***ret); void obt_prop_set32(Window win, Atom prop, Atom type, gulong val); void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val, guint num); -void obt_prop_set_string_locale(Window win, Atom prop, const gchar *val); -void obt_prop_set_string_utf8(Window win, Atom prop, const gchar *val); -void obt_prop_set_strings_locale(Window win, Atom prop, - const gchar *const *strs); -void obt_prop_set_strings_utf8(Window win, Atom prop, - const gchar *const *strs); +void obt_prop_set_text(Window win, Atom prop, const gchar *str); +void obt_prop_set_array_text(Window win, Atom prop, const gchar *const *strs); void obt_prop_erase(Window win, Atom prop); @@ -257,20 +275,33 @@ void obt_prop_message_to(Window to, Window about, Atom messagetype, #define OBT_PROP_GETA32(win, prop, type, ret, nret) \ (obt_prop_get_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \ ret, nret)) -#define OBT_PROP_GETS(win, prop, type, ret) \ - (obt_prop_get_string_##type(win, OBT_PROP_ATOM(prop), ret)) -#define OBT_PROP_GETSS(win, prop, type, ret) \ - (obt_prop_get_strings_##type(win, OBT_PROP_ATOM(prop), ret)) +#define OBT_PROP_GETS(win, prop, ret) \ + (obt_prop_get_text(win, OBT_PROP_ATOM(prop), 0, ret)) +#define OBT_PROP_GETSS(win, prop, ret) \ + (obt_prop_get_array_text(win, OBT_PROP_ATOM(prop), 0, ret)) + +#define OBT_PROP_GETS_TYPE(win, prop, type, ret) \ + (obt_prop_get_text(win, OBT_PROP_ATOM(prop), OBT_PROP_TEXT_##type, ret)) +#define OBT_PROP_GETSS_TYPE(win, prop, type, ret) \ + (obt_prop_get_array_text(win, OBT_PROP_ATOM(prop), \ + OBT_PROP_TEXT_##type, ret)) + +#define OBT_PROP_GETS_UTF8(win, prop, ret) \ + OBT_PROP_GETS_TYPE(win, prop, UTF8_STRING, ret) +#define OBT_PROP_GETSS_UTF8(win, prop, ret) \ + OBT_PROP_GETSS_TYPE(win, prop, UTF8_STRING, ret) +#define OBT_PROP_GETS_XPCS(win, prop, ret) \ + OBT_PROP_GETS_TYPE(win, prop, STRING_XPCS, ret) #define OBT_PROP_SET32(win, prop, type, val) \ (obt_prop_set32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), val)) #define OBT_PROP_SETA32(win, prop, type, val, num) \ (obt_prop_set_array32(win, OBT_PROP_ATOM(prop), OBT_PROP_ATOM(type), \ val, num)) -#define OBT_PROP_SETS(win, prop, type, val) \ - (obt_prop_set_string_##type(win, OBT_PROP_ATOM(prop), val)) -#define OBT_PROP_SETSS(win, prop, type, strs) \ - (obt_prop_set_strings_##type(win, OBT_PROP_ATOM(prop), strs)) +#define OBT_PROP_SETS(win, prop, val) \ + (obt_prop_set_text(win, OBT_PROP_ATOM(prop), val)) +#define OBT_PROP_SETSS(win, prop, strs) \ + (obt_prop_set_array_text(win, OBT_PROP_ATOM(prop), strs)) #define OBT_PROP_ERASE(win, prop) (obt_prop_erase(win, OBT_PROP_ATOM(prop))) diff --git a/openbox/client.c b/openbox/client.c index e666d589..012454c7 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1154,11 +1154,10 @@ static void client_get_all(ObClient *self, gboolean real) static void client_get_startup_id(ObClient *self) { - if (!(OBT_PROP_GETS(self->window, NET_STARTUP_ID, utf8, - &self->startup_id))) + if (!(OBT_PROP_GETS_UTF8(self->window, NET_STARTUP_ID, &self->startup_id))) if (self->group) - OBT_PROP_GETS(self->group->leader, - NET_STARTUP_ID, utf8, &self->startup_id); + OBT_PROP_GETS_UTF8(self->group->leader, NET_STARTUP_ID, + &self->startup_id); } static void client_get_area(ObClient *self) @@ -1969,15 +1968,14 @@ void client_update_title(ObClient *self) g_free(self->original_title); /* try netwm */ - if (!OBT_PROP_GETS(self->window, NET_WM_NAME, utf8, &data)) { + if (!OBT_PROP_GETS_UTF8(self->window, NET_WM_NAME, &data)) { /* try old x stuff */ - if (!(OBT_PROP_GETS(self->window, WM_NAME, locale, &data) - || OBT_PROP_GETS(self->window, WM_NAME, utf8, &data))) { + if (!OBT_PROP_GETS(self->window, WM_NAME, &data)) { if (self->transient) { - /* - GNOME alert windows are not given titles: - http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html - */ + /* + GNOME alert windows are not given titles: + http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html + */ data = g_strdup(""); } else data = g_strdup(_("Unnamed Window")); @@ -2000,7 +1998,7 @@ void client_update_title(ObClient *self) g_free(data); } - OBT_PROP_SETS(self->window, NET_WM_VISIBLE_NAME, utf8, visible); + OBT_PROP_SETS(self->window, NET_WM_VISIBLE_NAME, visible); self->title = visible; if (self->frame) @@ -2011,10 +2009,9 @@ void client_update_title(ObClient *self) g_free(self->icon_title); /* try netwm */ - if (!OBT_PROP_GETS(self->window, NET_WM_ICON_NAME, utf8, &data)) + if (!OBT_PROP_GETS_UTF8(self->window, NET_WM_ICON_NAME, &data)) /* try old x stuff */ - if (!(OBT_PROP_GETS(self->window, WM_ICON_NAME, locale, &data) || - OBT_PROP_GETS(self->window, WM_ICON_NAME, utf8, &data))) + if (!OBT_PROP_GETS(self->window, WM_ICON_NAME, &data)) data = g_strdup(self->title); if (self->client_machine) { @@ -2032,7 +2029,7 @@ void client_update_title(ObClient *self) g_free(data); } - OBT_PROP_SETS(self->window, NET_WM_VISIBLE_ICON_NAME, utf8, visible); + OBT_PROP_SETS(self->window, NET_WM_VISIBLE_ICON_NAME, visible); self->icon_title = visible; } @@ -2248,19 +2245,14 @@ static void client_get_session_ids(ObClient *self) leader = None; /* get the SM_CLIENT_ID */ - got = FALSE; - if (leader) - got = OBT_PROP_GETS(leader, SM_CLIENT_ID, locale, &self->sm_client_id); - if (!got) - OBT_PROP_GETS(self->window, SM_CLIENT_ID, locale, &self->sm_client_id); + if (leader && leader != self->window) + OBT_PROP_GETS_XPCS(leader, SM_CLIENT_ID, &self->sm_client_id); + else + OBT_PROP_GETS_XPCS(self->window, SM_CLIENT_ID, &self->sm_client_id); /* get the WM_CLASS (name and class). make them "" if they are not provided */ - got = FALSE; - if (leader) - got = OBT_PROP_GETSS(leader, WM_CLASS, locale, &ss); - if (!got) - got = OBT_PROP_GETSS(self->window, WM_CLASS, locale, &ss); + got = OBT_PROP_GETSS_TYPE(self->window, WM_CLASS, STRING_NO_CC, &ss); if (got) { if (ss[0]) { @@ -2275,11 +2267,7 @@ static void client_get_session_ids(ObClient *self) if (self->class == NULL) self->class = g_strdup(""); /* get the WM_WINDOW_ROLE. make it "" if it is not provided */ - got = FALSE; - if (leader) - got = OBT_PROP_GETS(leader, WM_WINDOW_ROLE, locale, &s); - if (!got) - got = OBT_PROP_GETS(self->window, WM_WINDOW_ROLE, locale, &s); + got = OBT_PROP_GETS_XPCS(self->window, WM_WINDOW_ROLE, &s); if (got) self->role = s; @@ -2290,9 +2278,9 @@ static void client_get_session_ids(ObClient *self) got = FALSE; if (leader) - got = OBT_PROP_GETSS(leader, WM_COMMAND, locale, &ss); + got = OBT_PROP_GETSS(leader, WM_COMMAND, &ss); if (!got) - got = OBT_PROP_GETSS(self->window, WM_COMMAND, locale, &ss); + got = OBT_PROP_GETSS(self->window, WM_COMMAND, &ss); if (got) { /* merge/mash them all together */ @@ -2315,9 +2303,9 @@ static void client_get_session_ids(ObClient *self) /* get the WM_CLIENT_MACHINE */ got = FALSE; if (leader) - got = OBT_PROP_GETS(leader, WM_CLIENT_MACHINE, locale, &s); + got = OBT_PROP_GETS(leader, WM_CLIENT_MACHINE, &s); if (!got) - got = OBT_PROP_GETS(self->window, WM_CLIENT_MACHINE, locale, &s); + got = OBT_PROP_GETS(self->window, WM_CLIENT_MACHINE, &s); if (got) { gchar localhost[128]; @@ -2344,10 +2332,10 @@ static void client_save_app_rule_values(ObClient *self) { const gchar *type; - OBT_PROP_SETS(self->window, OB_APP_ROLE, utf8, self->role); - OBT_PROP_SETS(self->window, OB_APP_NAME, utf8, self->name); - OBT_PROP_SETS(self->window, OB_APP_CLASS, utf8, self->class); - OBT_PROP_SETS(self->window, OB_APP_TITLE, utf8, self->original_title); + OBT_PROP_SETS(self->window, OB_APP_ROLE, self->role); + OBT_PROP_SETS(self->window, OB_APP_NAME, self->name); + OBT_PROP_SETS(self->window, OB_APP_CLASS, self->class); + OBT_PROP_SETS(self->window, OB_APP_TITLE, self->original_title); switch (self->type) { case OB_CLIENT_TYPE_NORMAL: @@ -2367,7 +2355,7 @@ static void client_save_app_rule_values(ObClient *self) case OB_CLIENT_TYPE_DOCK: type = "dock"; break; } - OBT_PROP_SETS(self->window, OB_APP_TYPE, utf8, type); + OBT_PROP_SETS(self->window, OB_APP_TYPE, type); } static void client_change_wm_state(ObClient *self) diff --git a/openbox/dock.c b/openbox/dock.c index 06d2280a..00abc530 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -145,7 +145,7 @@ void dock_manage(Window icon_win, Window name_win) app->name_win = name_win; app->icon_win = icon_win; - if (OBT_PROP_GETSS(app->name_win, WM_CLASS, locale, &data)) { + if (OBT_PROP_GETSS_TYPE(app->name_win, WM_CLASS, STRING_NO_CC, &data)) { if (data[0]) { app->name = g_strdup(data[0]); if (data[1]) diff --git a/openbox/openbox.c b/openbox/openbox.c index ae0ba8ae..9fd5fe40 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -258,8 +258,7 @@ gint main(gint argc, gchar **argv) gchar *p = g_filename_to_utf8(config_file, -1, NULL, NULL, NULL); if (p) - OBT_PROP_SETS(obt_root(ob_screen), OB_CONFIG_FILE, - utf8, p); + OBT_PROP_SETS(obt_root(ob_screen), OB_CONFIG_FILE, p); g_free(p); } else @@ -286,8 +285,8 @@ gint main(gint argc, gchar **argv) if (ob_rr_theme == NULL) ob_exit_with_error(_("Unable to load a theme.")); - OBT_PROP_SETS(obt_root(ob_screen), - OB_THEME, utf8, ob_rr_theme->name); + OBT_PROP_SETS(obt_root(ob_screen), OB_THEME, + ob_rr_theme->name); } if (reconfigure) { diff --git a/openbox/prompt.c b/openbox/prompt.c index 77398c5f..08356092 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -175,7 +175,7 @@ ObPrompt* prompt_new(const gchar *msg, const gchar *title, /* set the window's title */ if (title) - OBT_PROP_SETS(self->super.window, NET_WM_NAME, utf8, title); + OBT_PROP_SETS(self->super.window, NET_WM_NAME, title); /* listen for key presses on the window */ self->event_mask = KeyPressMask; diff --git a/openbox/screen.c b/openbox/screen.c index 353d2de0..4d73eeac 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -206,7 +206,7 @@ gboolean screen_annex(void) NET_SUPPORTING_WM_CHECK, WINDOW, screen_support_win); /* set properties on the supporting window */ - OBT_PROP_SETS(screen_support_win, NET_WM_NAME, utf8, "Openbox"); + OBT_PROP_SETS(screen_support_win, NET_WM_NAME, "Openbox"); OBT_PROP_SET32(screen_support_win, NET_SUPPORTING_WM_CHECK, WINDOW, screen_support_win); @@ -311,7 +311,7 @@ gboolean screen_annex(void) NET_SUPPORTED, ATOM, supported, num_support); g_free(supported); - OBT_PROP_SETS(RootWindow(obt_display, ob_screen), OB_VERSION, utf8, + OBT_PROP_SETS(RootWindow(obt_display, ob_screen), OB_VERSION, OPENBOX_VERSION); screen_tell_ksplash(); @@ -375,7 +375,7 @@ void screen_startup(gboolean reconfig) screen_resize(); /* have names already been set for the desktops? */ - if (OBT_PROP_GETSS(obt_root(ob_screen), NET_DESKTOP_NAMES, utf8, &names)) { + if (OBT_PROP_GETSS_UTF8(obt_root(ob_screen), NET_DESKTOP_NAMES, &names)) { g_strfreev(names); namesexist = TRUE; } @@ -397,7 +397,7 @@ void screen_startup(gboolean reconfig) /* set the root window property */ OBT_PROP_SETSS(obt_root(ob_screen), - NET_DESKTOP_NAMES, utf8, (const gchar*const*)names); + NET_DESKTOP_NAMES, (const gchar*const*)names); g_strfreev(names); } @@ -1182,7 +1182,7 @@ void screen_update_desktop_names(void) screen_desktop_names = NULL; if (OBT_PROP_GETSS(obt_root(ob_screen), - NET_DESKTOP_NAMES, utf8, &screen_desktop_names)) + NET_DESKTOP_NAMES, &screen_desktop_names)) for (i = 0; screen_desktop_names[i] && i < screen_num_desktops; ++i); else i = 0; @@ -1209,7 +1209,7 @@ void screen_update_desktop_names(void) /* if we changed any names, then set the root property so we can all agree on the names */ OBT_PROP_SETSS(obt_root(ob_screen), NET_DESKTOP_NAMES, - utf8, (const gchar*const*)screen_desktop_names); + (const gchar*const*)screen_desktop_names); } /* resize the pager for these names */