summary refs log tree commit diff
path: root/xutil.c
diff options
context:
space:
mode:
authorokan <okan>2010-05-22 22:32:08 +0000
committerokan <okan>2010-05-22 22:32:08 +0000
commite0c965777381ab74e54f84aac99f3fbd73e8573a (patch)
treea05918c36c552ac4a42723f9cbce6b9303eb9ad6 /xutil.c
parentf769df540d901b5b113a30de5356098aab81f427 (diff)
parent85a53083cbe06c33cdea95b6a9fcb953bcc3afa2 (diff)
downloadcwm-e0c965777381ab74e54f84aac99f3fbd73e8573a.tar.gz
cwm-e0c965777381ab74e54f84aac99f3fbd73e8573a.tar.xz
cwm-e0c965777381ab74e54f84aac99f3fbd73e8573a.zip
cvsimport
Diffstat (limited to 'xutil.c')
-rw-r--r--xutil.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/xutil.c b/xutil.c
index cbe7562..c57bea7 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 = 0;
+
+	*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;