diff options
author | okan <okan> | 2010-05-22 22:10:31 +0000 |
---|---|---|
committer | okan <okan> | 2010-05-22 22:10:31 +0000 |
commit | 72e6d2d0a9e3f1ac1c2fc52e03648c625b07a49c (patch) | |
tree | dd5bd9a49efd4c2b1b28eeac52353fcf22609a23 /xutil.c | |
parent | a292c96977547511316acc8e20798f7c2b1edb19 (diff) | |
download | cwm-72e6d2d0a9e3f1ac1c2fc52e03648c625b07a49c.tar.gz cwm-72e6d2d0a9e3f1ac1c2fc52e03648c625b07a49c.tar.xz cwm-72e6d2d0a9e3f1ac1c2fc52e03648c625b07a49c.zip |
replace XFetchName() with something more intelligent which attempts to
use the appropriate netwm Atom first, as well as deal with utf8. slightly different incarnation tested by sthen@ and ajacoutot@ - thanks! ok oga@
Diffstat (limited to 'xutil.c')
-rw-r--r-- | xutil.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/xutil.c b/xutil.c index cbe7562..2308173 100644 --- a/xutil.c +++ b/xutil.c @@ -152,6 +152,38 @@ xu_getprop(Window win, Atom atm, Atom type, long len, u_char **p) } int +xu_getstrprop(Window win, Atom atm, char **text) { + XTextProperty prop; + char **list; + int nitems; + + *text = NULL; + + XGetTextProperty(X_Dpy, win, &prop, atm); + if (!prop.nitems) + return (0); + + if (Xutf8TextPropertyToTextList(X_Dpy, &prop, &list, + &nitems) == Success && nitems > 0 && *list) { + if (nitems > 1) { + XTextProperty prop2; + if (Xutf8TextListToTextProperty(X_Dpy, list, nitems, + XUTF8StringStyle, &prop2) == Success) { + *text = xstrdup(prop2.value); + XFree(prop2.value); + } + } else { + *text = xstrdup(*list); + } + XFreeStringList(list); + } + + XFree(prop.value); + + return (nitems); +} + +int xu_getstate(struct client_ctx *cc, int *state) { long *p = NULL; |