lsw

lists window titles of X clients to stdout
git clone git://git.suckless.org/lsw
Log | Files | Refs | README | LICENSE

commit 0bcbd0cd548b2ab4246c4b7652cc6b72ce998272
parent 955a4e65bda4c1bbfaa4ab7bd39aaa9ea97b36ba
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Sat, 18 Jun 2011 03:48:12 +0100

fix prop encoding
Diffstat:
lsw.c | 15++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lsw.c b/lsw.c @@ -10,7 +10,6 @@ static void getname(Window win, char *buf, size_t size); static void lsw(Window win); static Atom netwmname; -static Bool aflag = False; static Bool lflag = False; static Display *dpy; @@ -29,8 +28,6 @@ main(int argc, char *argv[]) { puts("lsw-"VERSION", © 2006-2011 lsw engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } - else if(!strcmp(argv[i], "-a")) - aflag = True; else if(!strcmp(argv[i], "-l")) lflag = True; else @@ -55,11 +52,11 @@ lsw(Window win) { if(!XQueryTree(dpy, win, &dw, &dw, &wins, &n)) return; for(i = 0; i < n; i++) - if(aflag || (XGetWindowAttributes(dpy, wins[i], &wa) - && !wa.override_redirect && wa.map_state == IsViewable)) { + if(XGetWindowAttributes(dpy, wins[i], &wa) + && !wa.override_redirect && wa.map_state == IsViewable) { getname(wins[i], buf, sizeof buf); if(lflag) - printf("0x%lx %s\n", wins[i], buf); + printf("0x%07lx %s\n", wins[i], buf); else if(*buf) puts(buf); } @@ -76,11 +73,11 @@ getname(Window win, char *buf, size_t size) { if(!XGetTextProperty(dpy, win, &prop, netwmname) || prop.nitems == 0) if(!XGetWMName(dpy, win, &prop) || prop.nitems == 0) return; - if(prop.encoding == XA_STRING) - strncpy(buf, (char *)prop.value, size); - else if(!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) { + if(!XmbTextPropertyToTextList(dpy, &prop, &list, &n) && n > 0) { strncpy(buf, list[0], size); XFreeStringList(list); } + else + strncpy(buf, (char *)prop.value, size); XFree(prop.value); }