]> git.sur5r.net Git - i3/i3/blobdiff - src/x.c
Bugfix: Don’t warp the pointer if it already is on the target output (Thanks cls...
[i3/i3] / src / x.c
diff --git a/src/x.c b/src/x.c
index abfcebef402b428eaf6a5c5ebef91497215a3225..c2daca4c2f8538b18e6720fa06194e9cf2438639 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -290,7 +290,7 @@ void x_draw_decoration(Con *con) {
     /* find out which colors to use */
     if (con->urgent)
         p->color = &config.client.urgent;
-    else if (con == focused)
+    else if (con == focused || con_inside_focused(con))
         p->color = &config.client.focused;
     else if (con == TAILQ_FIRST(&(parent->focus_head)))
         p->color = &config.client.focused_inactive;
@@ -759,6 +759,12 @@ static void x_push_node_unmaps(Con *con) {
  */
 void x_push_changes(Con *con) {
     con_state *state;
+    xcb_query_pointer_cookie_t pointercookie;
+
+    /* If we need to warp later, we request the pointer position as soon as possible */
+    if (warp_to) {
+        pointercookie = xcb_query_pointer(conn, root);
+    }
 
     DLOG("-- PUSHING WINDOW STACK --\n");
     //DLOG("Disabling EnterNotify\n");
@@ -813,6 +819,9 @@ void x_push_changes(Con *con) {
     if (stacking_changed)
         ewmh_update_client_list_stacking(btt_stack, btt_stack_num);
 
+    DLOG("\n\n PUSHING CHANGES\n\n");
+    x_push_node(con);
+
     //DLOG("Re-enabling EnterNotify\n");
     values[0] = FRAME_EVENT_MASK;
     CIRCLEQ_FOREACH_REVERSE(state, &state_head, state) {
@@ -821,8 +830,6 @@ void x_push_changes(Con *con) {
     }
     //DLOG("Done, EnterNotify re-enabled\n");
 
-    DLOG("\n\n PUSHING CHANGES\n\n");
-    x_push_node(con);
     x_deco_recurse(con);
 
     xcb_window_t to_focus = focused->frame;
@@ -867,7 +874,18 @@ void x_push_changes(Con *con) {
     }
 
     if (warp_to) {
-        xcb_warp_pointer_rect(conn, 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;
     }