summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrl <brl>2007-07-19 09:08:48 +0000
committerbrl <brl>2007-07-19 09:08:48 +0000
commit281bbc7877da11d088adffaf01007641939bb118 (patch)
tree3eed3bcf3918f1d9272c48297ead8867f0dbf249
parent1ee117ef43bf221c9cc55e94a85c47aadf176f21 (diff)
downloadratpoison-281bbc7877da11d088adffaf01007641939bb118.zip
src/manage.c (get_wmname): always try XmbTextPropertyToTextList first to also support UTF-8 window titles when encoded as XA_STRING
-rw-r--r--ChangeLog5
-rw-r--r--src/manage.c42
2 files changed, 20 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 38c8195..7f69302 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-07 Bernhard R. Link <brlink@debian.org>
+
+ * src/manage.c (get_wmname): always try XmbTextPropertyToTextList
+ first to also support UTF-8 window titles when encoded as XA_STRING
+
2007-07-04 Bernhard R. Link <brlink@debian.org>
* src/main.c (clean_up): call free_user_commands, free_groups only
diff --git a/src/manage.c b/src/manage.c
index 1f94ee7..ad17cf7 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -198,39 +198,27 @@ update_normal_hints (rp_window *win)
static char *
get_wmname (Window w)
{
- unsigned char *name = NULL;
- char *ret;
+ char *name = NULL;
XTextProperty text_prop;
- int n;
+ int status, n;
char** cl;
if (XGetWMName(dpy, w, &text_prop) != 0) {
- if (text_prop.encoding == XA_STRING) {
- name = (char *)text_prop.value;
- } else {
- XmbTextPropertyToTextList(dpy, &text_prop, &cl, &n);
- XFree (text_prop.value);
- if (cl) {
- name = strdup(cl[0]);
- XFreeStringList(cl);
- } else {
- PRINT_DEBUG (("I can't get the WMName.\n"));
- return NULL;
- }
- }
- } else {
+ status = XmbTextPropertyToTextList(dpy, &text_prop, &cl, &n);
+ if (status == Success && cl && n > 0) {
+ name = xstrdup(cl[0]);
+ XFreeStringList(cl);
+ } else if (text_prop.encoding == XA_STRING) {
+ name = xstrdup((char*)text_prop.value);
+ }
+ XFree (text_prop.value);
+ }
+ if (name == NULL) {
PRINT_DEBUG (("I can't get the WMName.\n"));
- return NULL;
+ } else {
+ PRINT_DEBUG (("WM_NAME: '%s'\n", name));
}
-
- PRINT_DEBUG (("WM_NAME: '%s'\n", name));
-
- /* duplicate the string into our own buffer, and free the one given
- to us by X. */
- ret = xstrdup ((char *)name);
- XFree (name);
-
- return ret;
+ return name;
}
static XClassHint *