wmutils

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

commit 85eb6467a53fff9a6d5b7fb6b9b9c55ddc28de88
parent eb2dd623389bb641bedde940135c6467b8671cbc
Author: z3bra <willy@mailoo.org>
Date:   Wed Dec 17 12:13:13 2014

updated lsw to use get_windows()

Diffstat:
 lsw.c  | 14 +++-----------
 util.c |  8 +++++++-
 util.h |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/lsw.c b/lsw.c @@ -44,26 +44,18 @@ should_list(xcb_window_t w, int mask) static void list_windows(xcb_window_t w, int listmask) { - int i; + int i, wn; xcb_window_t *wc; - xcb_query_tree_cookie_t c; - xcb_query_tree_reply_t *r; - c = xcb_query_tree(conn, w); - r = xcb_query_tree_reply(conn, c, NULL); - if (r == NULL) - errx(1, "0x%08x: no such window", w); + wn = get_windows(conn, w, &wc); - wc = xcb_query_tree_children(r); if (wc == NULL) errx(1, "0x%08x: unable to retrieve children", w); - for (i=0; i<r->children_len; i++) { + for (i=0; i<wn; i++) { if (should_list(wc[i], listmask)) printf("0x%08x\n", wc[i]); } - - free(r); } int diff --git a/util.c b/util.c @@ -80,9 +80,10 @@ ignore(xcb_connection_t *con, xcb_window_t w) return or; } -void +int get_windows(xcb_connection_t *con, xcb_window_t w, xcb_window_t **l) { + int childnum = 0; xcb_query_tree_cookie_t c; xcb_query_tree_reply_t *r; @@ -92,4 +93,9 @@ get_windows(xcb_connection_t *con, xcb_window_t w, xcb_window_t **l) errx(1, "0x%08x: no such window", w); *l = xcb_query_tree_children(r); + + childnum = r->children_len; + free(r); + + return childnum; } diff --git a/util.h b/util.h @@ -5,7 +5,7 @@ void init_xcb(xcb_connection_t **); void kill_xcb(xcb_connection_t **); void get_screen(xcb_connection_t *, xcb_screen_t **); -void get_windows(xcb_connection_t *, xcb_window_t, xcb_window_t **); +int get_windows(xcb_connection_t *, xcb_window_t, xcb_window_t **); int exists(xcb_connection_t *, xcb_window_t); int mapped(xcb_connection_t *, xcb_window_t);