From 755c618cd41815c72d30fd0d3c4770557e952df2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 17 Sep 2011 20:53:24 +0100 Subject: [PATCH] =?UTF-8?q?Bugfix:=20Don=E2=80=99t=20warp=20the=20pointer?= =?UTF-8?q?=20if=20it=20already=20is=20on=20the=20target=20output=20(Thank?= =?UTF-8?q?s=20cls,=20pnutzh4x0r)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My testcase was putting a floating window on the left output, but overlapping a little to the right output. Then switch to a workspace on the right output. --- src/x.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/x.c b/src/x.c index b2105c2f..c2daca4c 100644 --- a/src/x.c +++ b/src/x.c @@ -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"); @@ -868,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; }