gm

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

commit eeb27b3fb7e9add340137d905a0f5763bb5aef51
parent 6c7840ce29a794b4b6f954ae4bf05567b38bfdeb
Author: z3bra <willy@mailoo.org>
Date:   Mon Nov 17 13:47:56 2014

removed 'grabkeys and regevnt' functions: need to fix things now

Diffstat:
 gm.c | 65 +++++++++++++++++++++++++----------------------------------------
 1 file changed, 25 insertions(+), 40 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,6 @@ 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 xcb_window_t focus; static uint8_t verbose = 0; /* verbose mode ? */ @@ -100,7 +98,7 @@ struct window *newnod(xcb_window_t w) return NULL; } - val[0] = winev; + val[0] = XCB_EVENT_MASK_KEY_PRESS; xcb_change_window_attributes(con, w, mask, val); xcb_flush(con); @@ -376,12 +374,12 @@ void evnt_keypress (xcb_generic_event_t *e) struct window *np; /* don't add the root window to a group */ - if (focus == scn->root) { + if (ev->event == scn->root) { return; } ks = getkeysym(ev->detail); - np = getnod(focus); + np = getnod(ev->event); if (!np) { warnx("evnt_keypress: cannot get focused window\n"); @@ -448,33 +446,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; @@ -561,17 +532,32 @@ void discover() void run() { + int i; xcb_generic_event_t *e; - static uint32_t mask = XCB_CW_EVENT_MASK; - static uint32_t val[] = { - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY - }; + static const uint32_t mask = XCB_CW_EVENT_MASK; + static uint32_t val[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY }; + xcb_query_tree_reply_t *r; + xcb_window_t *w; - xcb_change_window_attributes(con, scn->root, mask, val); + /* we fetch the win tree of the window */ + r = xcb_query_tree_reply(con, xcb_query_tree(con, scn->root), NULL); + + if (r == NULL) { + warnx("xcb_query_tree_reply"); + } + + w = xcb_query_tree_children(r); + + for (i = 0; i < r->children_len; i++) { + newnod(w[i]); + } xcb_flush(con); - val[0] = winev; - regevnt(val); + free(r); + + + xcb_change_window_attributes(con, scn->root, mask, val); + xcb_flush(con); for (;;) { e = xcb_wait_for_event(con); @@ -605,7 +591,6 @@ int main (int c, char **v) /* setup the X connection */ init(); discover(); - grabkeys(); /* ready... GO! */ run();