From 7d6e80b5ef8656bf35a8dc7471d36ad64ef279fb Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 27 Mar 2010 17:04:56 +0100 Subject: [PATCH] Bugfix: Ignore enter_notify when warping pointer (makes "goto" work correctly) --- include/handlers.h | 8 ++++++++ src/client.c | 8 +++++++- src/handlers.c | 8 +++++++- src/workspace.c | 5 ++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/handlers.h b/include/handlers.h index c7cbb322..7d0662e1 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -13,6 +13,14 @@ #include +/** + * Adds the sequence number of an event to the ignored events. + * Useful to ignore for example the enter notify caused by a pointer warp of + * i3. + * + */ +void add_ignore_event(const int sequence); + /** * There was a key press. We compare this key code with our bindings table and * pass the bound action to parse_command(). diff --git a/src/client.c b/src/client.c index 9c136ca6..ba3babe0 100644 --- a/src/client.c +++ b/src/client.c @@ -29,6 +29,7 @@ #include "workspace.h" #include "config.h" #include "log.h" +#include "handlers.h" /* * Removes the given client from the container, either because it will be inserted into another @@ -62,7 +63,12 @@ void client_remove_from_container(xcb_connection_t *conn, Client *client, Contai void client_warp_pointer_into(xcb_connection_t *conn, Client *client) { int mid_x = client->rect.width / 2, mid_y = client->rect.height / 2; - xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, mid_x, mid_y); + xcb_void_cookie_t cookie; + cookie = xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, mid_x, mid_y); + /* We need to add this event twice because we get one enter_notify for + * the child and one for the frame */ + add_ignore_event(cookie.sequence); + add_ignore_event(cookie.sequence); } /* diff --git a/src/handlers.c b/src/handlers.c index 624c3430..5eddf244 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -46,7 +46,13 @@ changing workspaces */ static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events; -static void add_ignore_event(const int sequence) { +/* + * Adds the sequence number of an event to the ignored events. + * Useful to ignore for example the enter notify caused by a pointer warp of + * i3. + * + */ +void add_ignore_event(const int sequence) { struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event)); event->sequence = sequence; diff --git a/src/workspace.c b/src/workspace.c index c950df8f..2798687d 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -29,6 +29,7 @@ #include "log.h" #include "ewmh.h" #include "ipc.h" +#include "handlers.h" /* * Returns a pointer to the workspace with the given number (starting at 0), @@ -139,8 +140,10 @@ void workspace_show(xcb_connection_t *conn, int workspace) { need_warp = true; else { Rect *dims = &(c_ws->output->rect); - xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, + xcb_void_cookie_t cookie; + cookie = xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, dims->x + (dims->width / 2), dims->y + (dims->height / 2)); + add_ignore_event(cookie.sequence); } /* Re-decorate the old client, it’s not focused anymore */