window: rework root_grabbuttons()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-17 14:35:58 +02:00
parent 514320a576
commit 5bae1f0c37
7 changed files with 20 additions and 65 deletions

View File

@ -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();

View File

@ -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. */

View File

@ -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;
}

View File

@ -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;

2
lua.c
View File

@ -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;
}

View File

@ -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

View File

@ -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);