gm

(orphaned) group manager using libcxb
git clone git://z3bra.org/gm
Log | Files | Refs | README | LICENSE

commit 72685611c95f9d664f71bcaa2057489a72c4b9a7
parent 098306e03f353f2f10b1ea36ba9be636fa0346c6
Author: z3bra <willy@mailoo.org>
Date:   Sat Nov 22 22:26:51 2014

removed regevnt() for the sake of modularity

Diffstat:
 gm.c | 40 ++++++++--------------------------------
 1 file changed, 8 insertions(+), 32 deletions(-)

diff --git a/gm.c b/gm.c @@ -46,7 +46,6 @@ void usage(char *); void cleanup (void); void init (void); void run (void); -void regevnt (uint32_t *); void grabkeys (void); xcb_keysym_t getkeysym (xcb_keycode_t); xcb_keycode_t * getkeycode (xcb_keysym_t); @@ -77,7 +76,7 @@ static struct window *groups[GROUPNUM + 1]; static xcb_connection_t *con; /* connection to the X server */ static xcb_screen_t *scn; /* default screen */ -static const uint32_t winev = XCB_EVENT_MASK_ENTER_WINDOW; +static const uint32_t xcb_events = XCB_EVENT_MASK_ENTER_WINDOW; static xcb_window_t focus; static uint8_t verbose = 0; /* verbose mode ? */ @@ -100,7 +99,7 @@ struct window *newnod(xcb_window_t w) return NULL; } - val[0] = winev; + val[0] = xcb_events; xcb_change_window_attributes(con, w, mask, val); xcb_flush(con); @@ -448,33 +447,6 @@ void cleanup() return; /* void */ } -/* change the events registration attribute of all the childs of parent */ -void regevnt(uint32_t *val) -{ - int i; - xcb_query_tree_reply_t *rep; - xcb_window_t *win; - static const uint32_t mask = XCB_CW_EVENT_MASK; - - /* we fetch the win tree of the window */ - rep = xcb_query_tree_reply(con, xcb_query_tree(con, scn->root), NULL); - - if (rep == NULL) { - warnx("xcb_query_tree_reply"); - } - - win = xcb_query_tree_children(rep); - - for (i = 0; i < rep->children_len; i++) { - xcb_change_window_attributes(con, win[i], mask, val); - } - xcb_flush(con); - - free(rep); - - return; /* void */ -} - xcb_keysym_t getkeysym (xcb_keycode_t keycode) { xcb_key_symbols_t *keysyms; @@ -535,6 +507,8 @@ void discover() xcb_query_tree_reply_t *r; xcb_window_t *w; struct window *np; + static const uint32_t mask = XCB_CW_EVENT_MASK; + static uint32_t val[2]; /* we fetch the w tree of the window */ r = xcb_query_tree_reply(con, xcb_query_tree(con, scn->root), NULL); @@ -544,12 +518,15 @@ void discover() } w = xcb_query_tree_children(r); + val[0] = xcb_events; + val[1] = XCB_NONE; for (i = 0; i < r->children_len; i++) { if (w[i] != scn->root) { np = newnod(w[i]); addgroup(np, GROUPDEF); xcb_map_window(con, np->id); + xcb_change_window_attributes(con, np->id, mask, val); } } xcb_flush(con); @@ -570,8 +547,7 @@ void run() xcb_change_window_attributes(con, scn->root, mask, val); xcb_flush(con); - val[0] = winev; - regevnt(val); + val[0] = xcb_events; for (;;) { e = xcb_wait_for_event(con);