From 460cad8bc8fef81461ca2fc35425c3f931468a71 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 28 Feb 2016 10:36:13 +0100 Subject: [PATCH] Fix grab keyboard to wait on success. --- source/x11-helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/x11-helper.c b/source/x11-helper.c index b5d20e9a..312b54ed 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -313,12 +313,16 @@ int take_keyboard ( xcb_connection_t *xcb_connection, xcb_window_t w ) { for ( int i = 0; i < 500; i++ ) { - xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb_connection, 1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, + xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb_connection, + 1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); xcb_grab_keyboard_reply_t *r = xcb_grab_keyboard_reply ( xcb_connection, cc, NULL); if ( r ) { + if ( r->status == XCB_GRAB_STATUS_SUCCESS) { + free(r); + return 1; + } free ( r ); - return 1; } usleep ( 1000 ); }