From 84ee8f1f92c1a2b5fe99716d17082e9a3f3d019e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 6 Mar 2009 14:01:29 +0100 Subject: [PATCH] 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 --- client.c | 10 +--------- client.h | 6 ++++++ event.c | 18 +----------------- layout.c | 30 ++++++++++++++++-------------- structs.h | 2 -- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/client.c b/client.c index 3600cc0b0..bb4350a18 100644 --- a/client.c +++ b/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)) { diff --git a/client.h b/client.h index 9bfd0a82e..0a944e2d8 100644 --- a/client.h +++ b/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) { diff --git a/event.c b/event.c index 844d56af0..995672d5d 100644 --- a/event.c +++ b/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); diff --git a/layout.c b/layout.c index 9541d4508..f4a5c094a 100644 --- a/layout.c +++ b/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 diff --git a/structs.h b/structs.h index 69e18a618..e07b521bf 100644 --- a/structs.h +++ b/structs.h @@ -325,8 +325,6 @@ struct awesome_t client_node_t *stack; /** Command line passed to awesome */ char *argv; - /** Last XMotionEvent coords */ - int pointer_x, pointer_y; /** Lua VM state */ lua_State *L; /** Default colors */