1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Grab keyboard as early as possible (#494)

This commit is contained in:
Dave Davenport 2016-11-06 16:50:12 +01:00
parent 0554db65ea
commit 89e3e0e645
2 changed files with 13 additions and 26 deletions

View file

@ -545,6 +545,19 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
/**
* Create window (without showing)
*/
// 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.
if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) {
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) );
if ( !has_keyboard ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
return FALSE;
}
take_pointer ( xcb_stuff_get_root_window ( xcb ) );
}
sleep(1);
TICK_N ( "Grab keyboard" );
__create_window ( window_flags );
TICK_N ( "Create Window" );
// Parse the keybindings.

View file

@ -1349,21 +1349,6 @@ RofiViewState *rofi_view_create ( Mode *sw,
TICK_N ( "Startup notification" );
// 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.
if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) {
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) );
if ( !has_keyboard ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
// Break off.
rofi_view_free ( state );
return NULL;
}
take_pointer ( xcb_stuff_get_root_window ( xcb ) );
}
TICK_N ( "Grab keyboard" );
// Get active monitor size.
TICK_N ( "Get active monitor" );
@ -1494,17 +1479,6 @@ int rofi_view_error_dialog ( const char *msg, int markup )
state->menu_flags = MENU_ERROR_DIALOG;
state->finalize = process_result;
// 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.
if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) {
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) );
if ( !has_keyboard ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
return FALSE;
}
take_pointer ( xcb_stuff_get_root_window ( xcb ) );
}
rofi_view_calculate_window_and_element_width ( state );
state->main_box = box_create ( BOX_VERTICAL,