mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Improvement of situation for Issue #153.
This commit is contained in:
parent
60a246b3f4
commit
bee103aea8
3 changed files with 42 additions and 23 deletions
|
@ -1,4 +1,6 @@
|
|||
0.15.5:
|
||||
Bug fixes:
|
||||
- Reduce time waiting for keyboard grab (#153)
|
||||
|
||||
0.15.4:
|
||||
New feature:
|
||||
|
|
|
@ -935,6 +935,21 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
|||
}
|
||||
workarea mon;
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
||||
if ( !has_keyboard ) {
|
||||
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
// main window isn't explicitly destroyed in case we switch modes. Reusing it prevents flicker
|
||||
XWindowAttributes attr;
|
||||
if ( main_window == None || XGetWindowAttributes ( display, main_window, &attr ) == 0 ) {
|
||||
|
@ -1071,7 +1086,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
|||
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
||||
|
||||
int x11_fd = ConnectionNumber ( display );
|
||||
int has_keyboard = take_keyboard ( display, main_window );
|
||||
while ( !state.quit ) {
|
||||
// Update if requested.
|
||||
if ( state.update ) {
|
||||
|
@ -1085,10 +1099,8 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
|||
MainLoopEvent mle = ML_XEVENT;
|
||||
// If we are in lazy mode, or trying to grab keyboard, go into timeout.
|
||||
// Otherwise continue like we had an XEvent (and we will block on fetching this event).
|
||||
if ( !has_keyboard || ( state.refilter && state.num_lines > config.lazy_filter_limit ) ) {
|
||||
if ( ( state.refilter && state.num_lines > config.lazy_filter_limit ) ) {
|
||||
mle = wait_for_xevent_or_timeout ( display, x11_fd );
|
||||
// Whatever happened, try to get keyboard.
|
||||
has_keyboard = take_keyboard ( display, main_window );
|
||||
}
|
||||
// If not in lazy mode, refilter.
|
||||
if ( state.num_lines <= config.lazy_filter_limit ) {
|
||||
|
@ -1291,6 +1303,22 @@ void error_dialog ( const char *msg )
|
|||
.update = TRUE,
|
||||
};
|
||||
workarea mon;
|
||||
|
||||
// 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 );
|
||||
}
|
||||
|
||||
if ( !has_keyboard ) {
|
||||
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
|
||||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
// Get active monitor size.
|
||||
monitor_active ( display, &mon );
|
||||
// main window isn't explicitly destroyed in case we switch modes. Reusing it prevents flicker
|
||||
|
@ -1323,8 +1351,6 @@ void error_dialog ( const char *msg )
|
|||
// Display it.
|
||||
XMapRaised ( display, main_window );
|
||||
|
||||
int x11_fd = ConnectionNumber ( display );
|
||||
int has_keyboard = take_keyboard ( display, main_window );
|
||||
while ( !state.quit ) {
|
||||
// Update if requested.
|
||||
if ( state.update ) {
|
||||
|
@ -1333,15 +1359,6 @@ void error_dialog ( const char *msg )
|
|||
}
|
||||
// Wait for event.
|
||||
XEvent ev;
|
||||
MainLoopEvent mle = ML_XEVENT;
|
||||
if ( !has_keyboard ) {
|
||||
mle = wait_for_xevent_or_timeout ( display, x11_fd );
|
||||
has_keyboard = take_keyboard ( display, main_window );
|
||||
}
|
||||
if ( mle == ML_TIMEOUT ) {
|
||||
// Loop.
|
||||
continue;
|
||||
}
|
||||
XNextEvent ( display, &ev );
|
||||
// Handle event.
|
||||
if ( ev.type == Expose ) {
|
||||
|
|
Loading…
Reference in a new issue