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:
Julien Danjou 2009-03-06 14:01:29 +01:00
parent 17e2d9e58f
commit 84ee8f1f92
5 changed files with 24 additions and 42 deletions

View File

@ -505,15 +505,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
client_t *c, *tc = NULL; client_t *c, *tc = NULL;
image_t *icon; image_t *icon;
int screen; int screen;
const uint32_t select_input_val[] = const uint32_t select_input_val[] = { 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
};
if(systray_iskdedockapp(w)) if(systray_iskdedockapp(w))
{ {

View File

@ -26,6 +26,12 @@
#include "stack.h" #include "stack.h"
#include "common/list.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 static void
client_delete(client_t **c) client_delete(client_t **c)
{ {

18
event.c
View File

@ -438,11 +438,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y))) &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); event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
}
return 0; return 0;
} }
@ -502,9 +498,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
widget_t *w; widget_t *w;
wibox_t *wibox; wibox_t *wibox;
if(ev->mode != XCB_NOTIFY_MODE_NORMAL if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
|| (ev->root_x == globalconf.pointer_x
&& ev->root_y == globalconf.pointer_y))
return 0; return 0;
if((wibox = wibox_getbywin(ev->event))) if((wibox = wibox_getbywin(ev->event)))
@ -513,11 +507,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y))) &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); event_handle_widget_motionnotify(wibox, &wibox->mouse_over, w);
}
if(wibox->mouse_enter != LUA_REFNIL) if(wibox->mouse_enter != LUA_REFNIL)
luaA_dofunction(globalconf.L, wibox->mouse_enter, 0, 0); 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)) else if((c = client_getbytitlebarwin(ev->event))
|| (c = client_getbywin(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) if(globalconf.hooks.mouse_enter != LUA_REFNIL)
{ {
luaA_client_userdata_new(globalconf.L, c); luaA_client_userdata_new(globalconf.L, c);

View File

@ -33,12 +33,18 @@ static void
arrange(int screen) arrange(int screen)
{ {
client_t *c; client_t *c;
int phys_screen = screen_virttophys(screen); uint32_t select_input_val[] = { CLIENT_SELECT_INPUT_EVENT_MASK & ~(XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW) };
xcb_query_pointer_cookie_t qp_c;
xcb_query_pointer_reply_t *qp_r;
for(c = globalconf.clients; c; c = c->next) 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)) if(client_isvisible(c, screen))
client_unban(c); client_unban(c);
/* we don't touch other screens windows */ /* we don't touch other screens windows */
@ -59,17 +65,13 @@ arrange(int screen)
luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0); luaA_dofunction(globalconf.L, globalconf.hooks.arrange, 1, 0);
} }
qp_c = xcb_query_pointer_unchecked(globalconf.connection, /* Now, we want to receive EnterNotify and LeaveNotify events back. */
xutil_screen_get(globalconf.connection, select_input_val[0] = CLIENT_SELECT_INPUT_EVENT_MASK;
phys_screen)->root); for(c = globalconf.clients; c; c = c->next)
xcb_change_window_attributes(globalconf.connection,
if((qp_r = xcb_query_pointer_reply(globalconf.connection, qp_c, NULL))) c->win,
{ XCB_CW_EVENT_MASK,
globalconf.pointer_x = qp_r->root_x; select_input_val);
globalconf.pointer_y = qp_r->root_y;
p_delete(&qp_r);
}
} }
/** Refresh the screen disposition /** Refresh the screen disposition

View File

@ -325,8 +325,6 @@ struct awesome_t
client_node_t *stack; client_node_t *stack;
/** Command line passed to awesome */ /** Command line passed to awesome */
char *argv; char *argv;
/** Last XMotionEvent coords */
int pointer_x, pointer_y;
/** Lua VM state */ /** Lua VM state */
lua_State *L; lua_State *L;
/** Default colors */ /** Default colors */