]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: warp pointer during the EnterNotify-disabled phase
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Oct 2011 21:29:47 +0000 (22:29 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 27 Oct 2011 21:29:47 +0000 (22:29 +0100)
Following bug:
1) Assign workspace 9 to output HDMI2
2) On HDMI2, be on workspace 1
3) Focus a different output, say LVDS1
4) Execute i3 'workspace 9'
5) Something happens, but you end up back on ws 1

(this is due to an EnterNotify being generated when warping)

src/x.c

diff --git a/src/x.c b/src/x.c
index 1acb7f3b296838cfd1bac4326dd3c126512590f4..61824d58bc57145a644988c007bcd18279b093ff 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -813,6 +813,22 @@ void x_push_changes(Con *con) {
     DLOG("PUSHING CHANGES\n");
     x_push_node(con);
 
+    if (warp_to) {
+        xcb_query_pointer_reply_t *pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL);
+        if (!pointerreply) {
+            ELOG("Could not query pointer position, not warping pointer\n");
+        } else {
+            int mid_x = warp_to->x + (warp_to->width / 2);
+            int mid_y = warp_to->y + (warp_to->height / 2);
+
+            Output *current = get_output_containing(pointerreply->root_x, pointerreply->root_y);
+            Output *target = get_output_containing(mid_x, mid_y);
+            if (current != target)
+                xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y);
+        }
+        warp_to = NULL;
+    }
+
     //DLOG("Re-enabling EnterNotify\n");
     values[0] = FRAME_EVENT_MASK;
     CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
@@ -863,22 +879,6 @@ void x_push_changes(Con *con) {
         focused_id = root;
     }
 
-    if (warp_to) {
-        xcb_query_pointer_reply_t *pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL);
-        if (!pointerreply) {
-            ELOG("Could not query pointer position, not warping pointer\n");
-        } else {
-            int mid_x = warp_to->x + (warp_to->width / 2);
-            int mid_y = warp_to->y + (warp_to->height / 2);
-
-            Output *current = get_output_containing(pointerreply->root_x, pointerreply->root_y);
-            Output *target = get_output_containing(mid_x, mid_y);
-            if (current != target)
-                xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y);
-        }
-        warp_to = NULL;
-    }
-
     xcb_flush(conn);
     DLOG("ENDING CHANGES\n");