From a974db887a88dfd56546bf9af6c7a7e762ba6746 Mon Sep 17 00:00:00 2001 From: QC Date: Sat, 2 May 2015 12:42:36 +0200 Subject: [PATCH] Fix issue #153. --- source/keyb.c | 1 - source/rofi.c | 16 ++-------------- source/x11-helper.c | 7 +++++-- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/source/keyb.c b/source/keyb.c index fd94d31e..e55ce208 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -104,7 +104,6 @@ DefaultBinding bindings[NUM_ABE] = }, { .id = ACCEPT_ENTRY, - // TODO: split Shift return in separate state. .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", }, diff --git a/source/rofi.c b/source/rofi.c index 24a1e6b0..7af31e8f 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -936,13 +936,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom // Try to grab the keyboard as early as possible. // We grab this using the rootwindow (as dmenu does it). // this seems to result in the smallest delay for most people. - // TODO: Merge this loop back into take_keyboard. - int has_keyboard = FALSE; - for ( int i = 0; i < 500 && - !( has_keyboard = take_keyboard ( display, DefaultRootWindow ( display ) ) ); - i++ ) { - usleep ( 1000 ); - } + int has_keyboard = take_keyboard ( display, DefaultRootWindow ( display ) ); if ( !has_keyboard ) { fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); @@ -1288,13 +1282,7 @@ void error_dialog ( const char *msg ) // Try to grab the keyboard as early as possible. // We grab this using the rootwindow (as dmenu does it). // this seems to result in the smallest delay for most people. - // TODO: Merge this loop back into take_keyboard. - int has_keyboard = FALSE; - for ( int i = 0; i < 500 && - !( has_keyboard = take_keyboard ( display, DefaultRootWindow ( display ) ) ); - i++ ) { - usleep ( 1000 ); - } + int has_keyboard = take_keyboard ( display, DefaultRootWindow ( display ) ); if ( !has_keyboard ) { fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); diff --git a/source/x11-helper.c b/source/x11-helper.c index 86cbe50c..0341dbbb 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -243,8 +243,11 @@ int window_send_message ( Display *display, Window target, int take_keyboard ( Display *display, Window w ) { - if ( XGrabKeyboard ( display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime ) == GrabSuccess ) { - return 1; + for ( int i = 0; i < 500; i++) { + if ( XGrabKeyboard ( display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime ) == GrabSuccess ) { + return 1; + } + usleep ( 1000 ); } return 0;