window: rework root_grabbuttons()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
514320a576
commit
5bae1f0c37
|
@ -467,9 +467,6 @@ main(int argc, char **argv)
|
||||||
systray_init(screen_nbr);
|
systray_init(screen_nbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call this to at least grab root window clicks */
|
|
||||||
window_root_grabbuttons();
|
|
||||||
|
|
||||||
/* scan existing windows */
|
/* scan existing windows */
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
|
|
3
client.c
3
client.c
|
@ -250,9 +250,6 @@ client_focus(client_t *c, int screen)
|
||||||
focus_client_push(c);
|
focus_client_push(c);
|
||||||
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
xcb_set_input_focus(globalconf.connection, XCB_INPUT_FOCUS_POINTER_ROOT,
|
||||||
c->win, XCB_CURRENT_TIME);
|
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;
|
phys_screen = c->phys_screen;
|
||||||
|
|
||||||
/* Some layouts use focused client differently, so call them back. */
|
/* Some layouts use focused client differently, so call them back. */
|
||||||
|
|
2
event.c
2
event.c
|
@ -343,7 +343,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
xcb_aux_get_screen(connection, emwin->phys_screen)->root,
|
xcb_aux_get_screen(connection, emwin->phys_screen)->root,
|
||||||
ANY_MODIFIER);
|
ANY_MODIFIER);
|
||||||
else
|
else
|
||||||
window_root_grabbuttons();
|
window_root_grabbuttons(ev->root);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
6
layout.c
6
layout.c
|
@ -65,8 +65,10 @@ arrange(int screen)
|
||||||
/* check that the mouse is on a window or not */
|
/* 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 = 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)
|
if(qp_r->child == XCB_NONE || qp_r->root == qp_r->child)
|
||||||
window_root_grabbuttons();
|
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_x = qp_r->root_x;
|
||||||
globalconf.pointer_y = qp_r->root_y;
|
globalconf.pointer_y = qp_r->root_y;
|
||||||
|
|
2
lua.c
2
lua.c
|
@ -82,8 +82,6 @@ luaA_mouse_add(lua_State *L)
|
||||||
button_list_push(&globalconf.buttons.root, *button);
|
button_list_push(&globalconf.buttons.root, *button);
|
||||||
button_ref(button);
|
button_ref(button);
|
||||||
|
|
||||||
window_root_grabbutton(*button);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
window.c
56
window.c
|
@ -107,11 +107,11 @@ window_configure(xcb_window_t win, area_t geometry, int border)
|
||||||
|
|
||||||
/** Grab or ungrab buttons on a window.
|
/** Grab or ungrab buttons on a window.
|
||||||
* \param win The window.
|
* \param win The window.
|
||||||
* \param phys_screen Physical screen number.
|
* \param root The root window.
|
||||||
* \param buttons The buttons to grab.
|
* \param buttons The buttons to grab.
|
||||||
*/
|
*/
|
||||||
void
|
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;
|
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);
|
b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY,
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY, root, ANY_MODIFIER);
|
||||||
xcb_aux_get_screen(globalconf.connection, phys_screen)->root,
|
|
||||||
ANY_MODIFIER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Grab all buttons on the root window.
|
/** Grab all buttons on the root window.
|
||||||
|
* \param root The root window.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
window_root_grabbuttons(void)
|
window_root_grabbuttons(xcb_window_t root)
|
||||||
{
|
{
|
||||||
button_t *b;
|
button_t *b;
|
||||||
xcb_screen_t *s;
|
|
||||||
int phys_screen = globalconf.default_screen;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
s = xcb_aux_get_screen(globalconf.connection, phys_screen);
|
|
||||||
for(b = globalconf.buttons.root; b; b = b->next)
|
for(b = globalconf.buttons.root; b; b = b->next)
|
||||||
{
|
{
|
||||||
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,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
b->button, b->mod);
|
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,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
b->button, b->mod | XCB_MOD_MASK_LOCK);
|
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,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
b->button, b->mod | globalconf.numlockmask);
|
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,
|
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC, XCB_NONE, XCB_NONE,
|
||||||
b->button, b->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
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_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 key on the root windows.
|
/** Grab key on the root windows.
|
||||||
|
|
5
window.h
5
window.h
|
@ -27,9 +27,8 @@
|
||||||
void window_setstate(xcb_window_t, long);
|
void window_setstate(xcb_window_t, long);
|
||||||
long window_getstate(xcb_window_t);
|
long window_getstate(xcb_window_t);
|
||||||
void window_configure(xcb_window_t, area_t, int);
|
void window_configure(xcb_window_t, area_t, int);
|
||||||
void window_grabbuttons(xcb_window_t, int, button_t *);
|
void window_grabbuttons(xcb_window_t, xcb_window_t, button_t *);
|
||||||
void window_root_grabbutton(button_t *);
|
void window_root_grabbuttons(xcb_window_t);
|
||||||
void window_root_grabbuttons(void);
|
|
||||||
void window_root_grabkey(keybinding_t *);
|
void window_root_grabkey(keybinding_t *);
|
||||||
void window_root_ungrabkey(keybinding_t *);
|
void window_root_ungrabkey(keybinding_t *);
|
||||||
void window_setshape(xcb_window_t, int);
|
void window_setshape(xcb_window_t, int);
|
||||||
|
|
Loading…
Reference in New Issue