aboutsummaryrefslogtreecommitdiffstats
path: root/xutil.c
diff options
context:
space:
mode:
authorokan2010-05-22 22:10:31 +0000
committerokan2010-05-22 22:10:31 +0000
commit8a70adb0c9439e853b0688eecfa1c041c2e20598 (patch)
tree0437ed3aeeb7314799e92f7937abac7af08dd24a /xutil.c
parent282d00dd063bedb53871f1b8a3dd09c3d4edc55f (diff)
downloadcwm-8a70adb0c9439e853b0688eecfa1c041c2e20598.tar.gz
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.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/xutil.c b/xutil.c
index 8164370..2b482f5 100644
--- a/xutil.c
+++ b/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: xutil.c,v 1.30 2010/04/11 16:51:26 okan Exp $
+ * $Id: xutil.c,v 1.31 2010/05/22 22:10:31 okan Exp $
*/
#include <sys/param.h>
@@ -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;