diff --git a/awesome.c b/awesome.c index 44c55c15..4bba4311 100644 --- a/awesome.c +++ b/awesome.c @@ -467,9 +467,6 @@ main(int argc, char **argv) systray_init(screen_nbr); } - /* call this to at least grab root window clicks */ - window_root_grabbuttons(); - /* scan existing windows */ scan(); diff --git a/client.c b/client.c index 1d8cc409..13694041 100644 --- a/client.c +++ b/client.c @@ -250,9 +250,6 @@ client_focus(client_t *c, int screen) focus_client_push(c); xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT, c->win, XCB_CURRENT_TIME); - /* since we're dropping EnterWindow events and sometimes the window - * will appear under the mouse, grabbuttons */ - window_grabbuttons(c->win, c->phys_screen, c->buttons); phys_screen = c->phys_screen; /* Some layouts use focused client differently, so call them back. */ diff --git a/event.c b/event.c index 4889a870..cb1d2f08 100644 --- a/event.c +++ b/event.c @@ -343,7 +343,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)), xcb_aux_get_screen(connection, emwin->phys_screen)->root, ANY_MODIFIER); else - window_root_grabbuttons(); + window_root_grabbuttons(ev->root); return 0; } diff --git a/layout.c b/layout.c index 84da94cb..8d10b23e 100644 --- a/layout.c +++ b/layout.c @@ -65,8 +65,10 @@ arrange(int screen) /* check that the mouse is on a window or not */ if((qp_r = xcb_query_pointer_reply(globalconf.connection, qp_c, NULL))) { - if(qp_r->root == XCB_NONE || qp_r->child == XCB_NONE || qp_r->root == qp_r->child) - window_root_grabbuttons(); + if(qp_r->child == XCB_NONE || qp_r->root == qp_r->child) + window_root_grabbuttons(qp_r->root); + else if ((c = client_getbywin(qp_r->child))) + window_grabbuttons(c->win, qp_r->root, c->buttons); globalconf.pointer_x = qp_r->root_x; globalconf.pointer_y = qp_r->root_y; diff --git a/lua.c b/lua.c index ff351d48..471d11d1 100644 --- a/lua.c +++ b/lua.c @@ -82,8 +82,6 @@ luaA_mouse_add(lua_State *L) button_list_push(&globalconf.buttons.root, *button); button_ref(button); - window_root_grabbutton(*button); - return 0; } diff --git a/window.c b/window.c index b8a94fea..49bc6a32 100644 --- a/window.c +++ b/window.c @@ -107,11 +107,11 @@ window_configure(xcb_window_t win, area_t geometry, int border) /** Grab or ungrab buttons on a window. * \param win The window. - * \param phys_screen Physical screen number. + * \param root The root window. * \param buttons The buttons to grab. */ void -window_grabbuttons(xcb_window_t win, int phys_screen, button_t *buttons) +window_grabbuttons(xcb_window_t win, xcb_window_t root, button_t *buttons) { button_t *b; @@ -131,70 +131,32 @@ window_grabbuttons(xcb_window_t win, int phys_screen, button_t *buttons) b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK); } - xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, - xcb_aux_get_screen(globalconf.connection, phys_screen)->root, - ANY_MODIFIER); + xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, root, ANY_MODIFIER); } /** Grab all buttons on the root window. + * \param root The root window. */ void -window_root_grabbuttons(void) +window_root_grabbuttons(xcb_window_t root) { button_t *b; - xcb_screen_t *s; - int phys_screen = globalconf.default_screen; - do + for(b = globalconf.buttons.root; b; b = b->next) { - s = xcb_aux_get_screen(globalconf.connection, phys_screen); - for(b = globalconf.buttons.root; b; b = b->next) - { - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, - b->button, b->mod); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, - b->button, b->mod | XCB_MOD_MASK_LOCK); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, - b->button, b->mod | globalconf.numlockmask); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, - b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK); - } - phys_screen++; - } while(!globalconf.screens_info->xinerama_is_active - && phys_screen < globalconf.screens_info->nscreen); -} - -/** Grab button on the root window. - * \param b The button binding. - */ -void -window_root_grabbutton(button_t *b) -{ - xcb_screen_t *s; - int phys_screen = globalconf.default_screen; - - do - { - s = xcb_aux_get_screen(globalconf.connection, phys_screen); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, + xcb_grab_button(globalconf.connection, false, root, BUTTONMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, b->button, b->mod); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, + xcb_grab_button(globalconf.connection, false, root, BUTTONMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, b->button, b->mod | XCB_MOD_MASK_LOCK); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, + xcb_grab_button(globalconf.connection, false, root, BUTTONMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, b->button, b->mod | globalconf.numlockmask); - xcb_grab_button(globalconf.connection, false, s->root, BUTTONMASK, + xcb_grab_button(globalconf.connection, false, root, BUTTONMASK, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE, b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK); - phys_screen++; - } while(!globalconf.screens_info->xinerama_is_active - && phys_screen < globalconf.screens_info->nscreen); + } } /** Grab key on the root windows. @@ -206,7 +168,7 @@ window_root_grabkey(keybinding_t *k) int phys_screen = globalconf.default_screen; xcb_screen_t *s; xcb_keycode_t kc; - + if((kc = k->keycode) || (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym)))) do @@ -235,7 +197,7 @@ window_root_ungrabkey(keybinding_t *k) int phys_screen = globalconf.default_screen; xcb_screen_t *s; xcb_keycode_t kc; - + if((kc = k->keycode) || (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym)))) do diff --git a/window.h b/window.h index 3d83b969..0b770d94 100644 --- a/window.h +++ b/window.h @@ -27,9 +27,8 @@ void window_setstate(xcb_window_t, long); long window_getstate(xcb_window_t); void window_configure(xcb_window_t, area_t, int); -void window_grabbuttons(xcb_window_t, int, button_t *); -void window_root_grabbutton(button_t *); -void window_root_grabbuttons(void); +void window_grabbuttons(xcb_window_t, xcb_window_t, button_t *); +void window_root_grabbuttons(xcb_window_t); void window_root_grabkey(keybinding_t *); void window_root_ungrabkey(keybinding_t *); void window_setshape(xcb_window_t, int);