tupdated lsw to use get_windows() - wmutils - X windows manipulation utilities
(HTM) git clone git://z3bra.org/wmutils
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 85eb6467a53fff9a6d5b7fb6b9b9c55ddc28de88
(DIR) parent eb2dd623389bb641bedde940135c6467b8671cbc
(HTM) Author: z3bra <willy@mailoo.org>
Date: Wed, 17 Dec 2014 12:13:13 +0100
updated lsw to use get_windows()
Diffstat:
M lsw.c | 14 +++-----------
M util.c | 8 +++++++-
M util.h | 2 +-
3 files changed, 11 insertions(+), 13 deletions(-)
---
(DIR) diff --git a/lsw.c b/lsw.c
t@@ -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
(DIR) diff --git a/util.c b/util.c
t@@ -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;
t@@ -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;
}
(DIR) diff --git a/util.h b/util.h
t@@ -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);