From: Michael Stapelberg Date: Thu, 27 Dec 2012 16:04:13 +0000 (+0100) Subject: ignore MotionNotify events generated while warping the pointer X-Git-Tag: 4.5~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d8e27dd5aa2f495c9f18de4ef34fa6966a9cc8ec;p=i3%2Fi3 ignore MotionNotify events generated while warping the pointer --- diff --git a/include/xcb.h b/include/xcb.h index 15d3e28f..54013569 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -45,6 +45,15 @@ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | /* …subwindows get notifies */ \ XCB_EVENT_MASK_ENTER_WINDOW) /* …user moves cursor inside our window */ +#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | \ + XCB_EVENT_MASK_BUTTON_PRESS | \ + XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video \ + projector), the root window gets a \ + ConfigureNotify */ \ + XCB_EVENT_MASK_POINTER_MOTION | \ + XCB_EVENT_MASK_PROPERTY_CHANGE | \ + XCB_EVENT_MASK_ENTER_WINDOW) + #define xmacro(atom) xcb_atom_t A_ ## atom; #include "atoms.xmacro" #undef xmacro diff --git a/src/main.c b/src/main.c index 1369f4bb..78a84fe2 100644 --- a/src/main.c +++ b/src/main.c @@ -541,17 +541,8 @@ int main(int argc, char *argv[]) { config.ipc_socket_path = sstrdup(config.ipc_socket_path); } - uint32_t mask = XCB_CW_EVENT_MASK; - uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | - XCB_EVENT_MASK_BUTTON_PRESS | - XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video - projector), the root window gets a - ConfigureNotify */ - XCB_EVENT_MASK_POINTER_MOTION | - XCB_EVENT_MASK_PROPERTY_CHANGE | - XCB_EVENT_MASK_ENTER_WINDOW }; xcb_void_cookie_t cookie; - cookie = xcb_change_window_attributes_checked(conn, root, mask, values); + cookie = xcb_change_window_attributes_checked(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ ROOT_EVENT_MASK }); check_error(conn, cookie, "Another window manager seems to be running"); xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(conn, gcookie, NULL); diff --git a/src/x.c b/src/x.c index e3b31bfa..fcb63c35 100644 --- a/src/x.c +++ b/src/x.c @@ -920,8 +920,12 @@ void x_push_changes(Con *con) { Output *current = get_output_containing(pointerreply->root_x, pointerreply->root_y); Output *target = get_output_containing(mid_x, mid_y); - if (current != target) + if (current != target) { + /* Ignore MotionNotify events generated by warping */ + xcb_change_window_attributes(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT }); xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y); + xcb_change_window_attributes(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ ROOT_EVENT_MASK }); + } } warp_to = NULL; }