event: implements Bob Marley version 2
Version 1 was supposed to store somehow the mouse coordinates to drop spurious EnterNotify. Now, we use a simpler way: we just tell the X server we do not want to receive this events while we are arranging, since we would get spurious ones. Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
17e2d9e58f
commit
84ee8f1f92
10
client.c
10
client.c
|
@ -505,15 +505,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
|||
client_t *c, *tc = NULL;
|
||||
image_t *icon;
|
||||
int screen;
|
||||
const uint32_t select_input_val[] =
|
||||
{
|
||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
| XCB_EVENT_MASK_PROPERTY_CHANGE
|
||||
| XCB_EVENT_MASK_ENTER_WINDOW
|
||||
| XCB_EVENT_MASK_LEAVE_WINDOW
|
||||
| XCB_EVENT_MASK_FOCUS_CHANGE
|
||||
};
|
||||
|
||||
const uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK };
|
||||
|
||||
if(systray_iskdedockapp(w))
|
||||
{
|
||||
|
|
6
client.h
6
client.h
|
@ -26,6 +26,12 @@
|
|||
#include "stack.h"
|
||||
#include "common/list.h"
|
||||
|
||||
#define CLIENT_SELECT_INPUT_EVENT_MASK (XCB_EVENT_MASK_STRUCTURE_NOTIFY \
|
||||
| XCB_EVENT_MASK_PROPERTY_CHANGE \
|
||||
| XCB_EVENT_MASK_ENTER_WINDOW \
|
||||
| XCB_EVENT_MASK_LEAVE_WINDOW \
|
||||
| XCB_EVENT_MASK_FOCUS_CHANGE)
|
||||
|
||||
static void
|
||||
client_delete(client_t **c)
|
||||
{
|
||||
|
|
18
event.c
18
event.c
|
@ -438,11 +438,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
|
|||
wibox->sw.geometry.width,
|
||||
wibox->sw.geometry.height,
|
||||
&ev->event_x, &ev->event_y)))
|
||||
{
|
||||
globalconf.pointer_x = ev->root_x;
|
||||
globalconf.pointer_y = ev->root_y;
|
||||
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -502,9 +498,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
|||
widget_t *w;
|
||||
wibox_t *wibox;
|
||||
|
||||
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
||||
|| (ev->root_x == globalconf.pointer_x
|
||||
&& ev->root_y == globalconf.pointer_y))
|
||||
if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
|
||||
return 0;
|
||||
|
||||
if((wibox = wibox_getbywin(ev->event)))
|
||||
|
@ -513,11 +507,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
|||
wibox->sw.geometry.width,
|
||||
wibox->sw.geometry.height,
|
||||
&ev->event_x, &ev->event_y)))
|
||||
{
|
||||
globalconf.pointer_x = ev->root_x;
|
||||
globalconf.pointer_y = ev->root_y;
|
||||
event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
|
||||
}
|
||||
|
||||
if(wibox->mouse_enter != LUA_REFNIL)
|
||||
luaA_dofunction(globalconf.L, wibox->mouse_enter, 0, 0);
|
||||
|
@ -525,12 +515,6 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
|||
else if((c = client_getbytitlebarwin(ev->event))
|
||||
|| (c = client_getbywin(ev->event)))
|
||||
{
|
||||
/* The idea behind saving pointer_x and pointer_y is Bob Marley powered.
|
||||
* this will allow us top drop some EnterNotify events and thus not giving
|
||||
* focus to windows appering under the cursor without a cursor move */
|
||||
globalconf.pointer_x = ev->root_x;
|
||||
globalconf.pointer_y = ev->root_y;
|
||||
|
||||
if(globalconf.hooks.mouse_enter != LUA_REFNIL)
|
||||
{
|
||||
luaA_client_userdata_new(globalconf.L, c);
|
||||
|
|
30
layout.c
30
layout.c
|
@ -33,12 +33,18 @@ static void
|
|||
arrange(int screen)
|
||||
{
|
||||
client_t *c;
|
||||
int phys_screen = screen_virttophys(screen);
|
||||
xcb_query_pointer_cookie_t qp_c;
|
||||
xcb_query_pointer_reply_t *qp_r;
|
||||
uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) };
|
||||
|
||||
for(c = globalconf.clients; c; c = c->next)
|
||||
{
|
||||
/* Bob Marley v2:
|
||||
* While we arrange, we do not want to receive EnterNotify or LeaveNotify
|
||||
* events, or we would get spurious events. */
|
||||
xcb_change_window_attributes(globalconf.connection,
|
||||
c->win,
|
||||
XCB_CW_EVENT_MASK,
|
||||
select_input_val);
|
||||
|
||||
if(client_isvisible(c, screen))
|
||||
client_unban(c);
|
||||
/* we don't touch other screens windows */
|
||||
|
@ -59,17 +65,13 @@ arrange(int screen)
|
|||
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
|
||||
}
|
||||
|
||||
qp_c = xcb_query_pointer_unchecked(globalconf.connection,
|
||||
xutil_screen_get(globalconf.connection,
|
||||
phys_screen)->root);
|
||||
|
||||
if((qp_r = xcb_query_pointer_reply(globalconf.connection, qp_c, NULL)))
|
||||
{
|
||||
globalconf.pointer_x = qp_r->root_x;
|
||||
globalconf.pointer_y = qp_r->root_y;
|
||||
|
||||
p_delete(&qp_r);
|
||||
}
|
||||
/* Now, we want to receive EnterNotify and LeaveNotify events back. */
|
||||
select_input_val[0] = CLIENT_SELECT_INPUT_EVENT_MASK;
|
||||
for(c = globalconf.clients; c; c = c->next)
|
||||
xcb_change_window_attributes(globalconf.connection,
|
||||
c->win,
|
||||
XCB_CW_EVENT_MASK,
|
||||
select_input_val);
|
||||
}
|
||||
|
||||
/** Refresh the screen disposition
|
||||
|
|
Loading…
Reference in New Issue