mirror of https://github.com/davatorium/rofi.git
Improvement of situation for Issue #153.
This commit is contained in:
parent
60a246b3f4
commit
bee103aea8
|
@ -1,4 +1,6 @@
|
||||||
0.15.5:
|
0.15.5:
|
||||||
|
Bug fixes:
|
||||||
|
- Reduce time waiting for keyboard grab (#153)
|
||||||
|
|
||||||
0.15.4:
|
0.15.4:
|
||||||
New feature:
|
New feature:
|
||||||
|
|
|
@ -23,12 +23,12 @@ typedef struct
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TB_AUTOHEIGHT = 1 << 0,
|
TB_AUTOHEIGHT = 1 << 0,
|
||||||
TB_AUTOWIDTH = 1 << 1,
|
TB_AUTOWIDTH = 1 << 1,
|
||||||
TB_LEFT = 1 << 16,
|
TB_LEFT = 1 << 16,
|
||||||
TB_RIGHT = 1 << 17,
|
TB_RIGHT = 1 << 17,
|
||||||
TB_CENTER = 1 << 18,
|
TB_CENTER = 1 << 18,
|
||||||
TB_EDITABLE = 1 << 19,
|
TB_EDITABLE = 1 << 19,
|
||||||
} TextboxFlags;
|
} TextboxFlags;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -935,6 +935,21 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
}
|
}
|
||||||
workarea mon;
|
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
|
// main window isn't explicitly destroyed in case we switch modes. Reusing it prevents flicker
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
if ( main_window == None || XGetWindowAttributes ( display, main_window, &attr ) == 0 ) {
|
if ( main_window == None || XGetWindowAttributes ( display, main_window, &attr ) == 0 ) {
|
||||||
|
@ -1070,8 +1085,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
state.quit = FALSE;
|
state.quit = FALSE;
|
||||||
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive );
|
||||||
|
|
||||||
int x11_fd = ConnectionNumber ( display );
|
int x11_fd = ConnectionNumber ( display );
|
||||||
int has_keyboard = take_keyboard ( display, main_window );
|
|
||||||
while ( !state.quit ) {
|
while ( !state.quit ) {
|
||||||
// Update if requested.
|
// Update if requested.
|
||||||
if ( state.update ) {
|
if ( state.update ) {
|
||||||
|
@ -1085,10 +1099,8 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
MainLoopEvent mle = ML_XEVENT;
|
MainLoopEvent mle = ML_XEVENT;
|
||||||
// If we are in lazy mode, or trying to grab keyboard, go into timeout.
|
// 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).
|
// 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 );
|
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 not in lazy mode, refilter.
|
||||||
if ( state.num_lines <= config.lazy_filter_limit ) {
|
if ( state.num_lines <= config.lazy_filter_limit ) {
|
||||||
|
@ -1291,6 +1303,22 @@ void error_dialog ( const char *msg )
|
||||||
.update = TRUE,
|
.update = TRUE,
|
||||||
};
|
};
|
||||||
workarea mon;
|
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.
|
// Get active monitor size.
|
||||||
monitor_active ( display, &mon );
|
monitor_active ( display, &mon );
|
||||||
// main window isn't explicitly destroyed in case we switch modes. Reusing it prevents flicker
|
// 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.
|
// Display it.
|
||||||
XMapRaised ( display, main_window );
|
XMapRaised ( display, main_window );
|
||||||
|
|
||||||
int x11_fd = ConnectionNumber ( display );
|
|
||||||
int has_keyboard = take_keyboard ( display, main_window );
|
|
||||||
while ( !state.quit ) {
|
while ( !state.quit ) {
|
||||||
// Update if requested.
|
// Update if requested.
|
||||||
if ( state.update ) {
|
if ( state.update ) {
|
||||||
|
@ -1332,16 +1358,7 @@ void error_dialog ( const char *msg )
|
||||||
state.update = FALSE;
|
state.update = FALSE;
|
||||||
}
|
}
|
||||||
// Wait for event.
|
// Wait for event.
|
||||||
XEvent ev;
|
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 );
|
XNextEvent ( display, &ev );
|
||||||
// Handle event.
|
// Handle event.
|
||||||
if ( ev.type == Expose ) {
|
if ( ev.type == Expose ) {
|
||||||
|
|
Loading…
Reference in New Issue