wmutils

X windows manipulation utilities
git clone git://z3bra.org/wmutils
Log | Files | Refs | LICENSE

commit d73c716df2a3b7152cb0371ee0017e9276843af3
parent eadb96606dcdb8ad731019c1ec72f9de9e8a9068
Author: z3bra <willy@mailoo.org>
Date:   Fri Dec 19 00:52:56 2014

fixed the exists() behavior in wattr

Diffstat:
 wattr.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/wattr.c b/wattr.c @@ -57,7 +57,7 @@ getattribute(xcb_window_t w, int attr) int main(int argc, char **argv) { - int c; + int c, retval = 0; size_t i; xcb_window_t w = 0; @@ -68,6 +68,11 @@ main(int argc, char **argv) init_xcb(&conn); + if (argc == 2) { + w = strtoul(argv[1], NULL, 16); + retval = exists(conn, w) ? 0 : 1; + } + for (c=2; argv[c]; c++) { w = strtoul(argv[c], NULL, 16); @@ -75,19 +80,13 @@ main(int argc, char **argv) switch (argv[1][i]) { case 'i': printf("0x%08x", w); break; - case 'b': printf("%d", getattribute(w, ATTR_B)); - break; - case 'h': printf("%d", getattribute(w, ATTR_H)); - break; - case 'x': printf("%d", getattribute(w, ATTR_X)); - break; - case 'y': printf("%d", getattribute(w, ATTR_Y)); - break; - case 'w': printf("%d", getattribute(w, ATTR_W)); - break; - case 'o': ignore(conn, w) ? exit(0) : exit(1); - case 'm': mapped(conn, w) ? exit(0) : exit(1); - default : exists(conn, w) ? exit(0) : exit(1); + case 'b': printf("%d", getattribute(w, ATTR_B));break; + case 'h': printf("%d", getattribute(w, ATTR_H));break; + case 'x': printf("%d", getattribute(w, ATTR_X));break; + case 'y': printf("%d", getattribute(w, ATTR_Y));break; + case 'w': printf("%d", getattribute(w, ATTR_W));break; + case 'o': retval = ignore(conn, w) ? 0 : 1; + case 'm': retval = mapped(conn, w) ? 0 : 1; } /* add a space if more attribute come after */ putc(i+1 < strlen(argv[1]) ? ' ' : '\n',stdout); @@ -96,5 +95,5 @@ main(int argc, char **argv) kill_xcb(&conn); - return 0; + return retval; }