diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 3732131e..891a0df3 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -215,9 +215,9 @@ Select the scrolling method. 0: Per page, 1: continuous. Hide the indicator that shows what part of the string is matched. -`-lazy-grab` +`-no-lazy-grab` -When fail to grab keyboard, don't block but retry later in background. +Disables lazy grab, this forces the keyboard being grabbed before gui is shown. ### Theming diff --git a/doc/rofi.1 b/doc/rofi.1 index 75872cbe..c618f32b 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-MANPAGE" "" "February 2017" "" "" +.TH "ROFI\-MANPAGE" "" "2017-02-02" "" "" . .SH "NAME" \fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement @@ -304,10 +304,10 @@ Select the scrolling method\. 0: Per page, 1: continuous\. Hide the indicator that shows what part of the string is matched\. . .P -\fB\-lazy\-grab\fR +\fB\-no\-lazy\-grab\fR . .P -When fail to grab keyboard, don\'t block but retry later in background\. +Disables lazy grab, this forces the keyboard being grabbed before gui is shown\. . .SS "Theming" All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names\. diff --git a/source/rofi.c b/source/rofi.c index ea54565a..2bc57024 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -261,7 +261,7 @@ static void print_main_application_options ( int is_term ) print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term ); print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term ); print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term ); - print_help_msg ( "-lazy-grab", "", "When fail to grab keyboard, don't block but retry later.", NULL, is_term ); + print_help_msg ( "-no-lazy-grab", "", "Disable lazy grab that, when fail to grab keyboard, does not block but retry later.", NULL, is_term ); } static void help ( G_GNUC_UNUSED int argc, char **argv ) { @@ -650,15 +650,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) // We grab this using the rootwindow (as dmenu does it). // this seems to result in the smallest delay for most people. if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) { - if ( find_arg ( "-lazy-grab" ) >= 0 ) { - if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { - g_timeout_add ( 1, lazy_grab_keyboard, NULL ); - } - if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { - g_timeout_add ( 1, lazy_grab_pointer, NULL ); - } - } - else { + if ( find_arg ( "-no-lazy-grab" ) >= 0 ) { if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 500 ) ) { fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); g_main_loop_quit ( main_loop ); @@ -668,6 +660,14 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 ); } } + else { + if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { + g_timeout_add ( 1, lazy_grab_keyboard, NULL ); + } + if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { + g_timeout_add ( 1, lazy_grab_pointer, NULL ); + } + } } TICK_N ( "Grab keyboard" ); __create_window ( window_flags );