[hackers] [lsw] fix prop encoding || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Sat, 18 Jun 2011 04:48:17 +0200 (CEST)

changeset: 12:cddbc36a1e1c
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sat Jun 18 03:48:12 2011 +0100
files: lsw.c
description:
fix prop encoding

diff -r 4a1c37e8b212 -r cddbc36a1e1c lsw.c
--- a/lsw.c Sat Jun 18 03:24:26 2011 +0100
+++ b/lsw.c Sat Jun 18 03:48:12 2011 +0100
@@ -10,7 +10,6 @@
 static void lsw(Window win);
 
 static Atom netwmname;
-static Bool aflag = False;
 static Bool lflag = False;
 static Display *dpy;
 
@@ -29,8 +28,6 @@
                         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 @@
         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 @@
         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);
 }
Received on Sat Jun 18 2011 - 04:48:17 CEST

This archive was generated by hypermail 2.2.0 : Sat Jun 18 2011 - 05:00:07 CEST