]> git.sur5r.net Git - i3/i3/commitdiff
ignore MotionNotify events generated while warping the pointer
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Dec 2012 16:04:13 +0000 (17:04 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Dec 2012 16:04:13 +0000 (17:04 +0100)
include/xcb.h
src/main.c
src/x.c

index 15d3e28fc4e1e81dbd8020fcd960ce6ba9b3f739..540135694187e9a6d2e4f896ca60844b0d61cdd8 100644 (file)
                           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
index 1369f4bbe76b4b607122b66a9b8693bcca194a94..78a84fe29a676af3a6d29d33abb8666f774c1a63 100644 (file)
@@ -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 e3b31bfa2709e66ac56395539d9a6a61f5d57a1b..fcb63c35bdef19765540800ecb610011ced1941a 100644 (file)
--- 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;
     }