diff --git a/source/rofi.c b/source/rofi.c index 1e581a3f..e21c80eb 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -419,6 +419,10 @@ static void menu_calculate_window_and_element_width ( MenuState *state, workarea */ inline static void menu_nav_page_next ( MenuState *state ) { + // If no lines, do nothing. + if ( state->filtered_lines == 0 ) { + return; + } state->selected += ( state->max_elements ); if ( state->selected >= state->filtered_lines ) { state->selected = state->filtered_lines - 1; @@ -451,6 +455,10 @@ inline static void menu_nav_page_prev ( MenuState * state ) */ inline static void menu_nav_right ( MenuState *state ) { + // If no lines, do nothing. + if ( state->filtered_lines == 0 ) { + return; + } if ( ( state->selected + state->max_rows ) < state->filtered_lines ) { state->selected += state->max_rows; state->update = TRUE; @@ -508,6 +516,10 @@ inline static void menu_nav_up ( MenuState *state ) */ inline static void menu_nav_down ( MenuState *state ) { + // If no lines, do nothing. + if ( state->filtered_lines == 0 ) { + return; + } state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0; state->update = TRUE; } @@ -528,6 +540,10 @@ inline static void menu_nav_first ( MenuState * state ) */ inline static void menu_nav_last ( MenuState * state ) { + // If no lines, do nothing. + if ( state->filtered_lines == 0 ) { + return; + } state->selected = state->filtered_lines - 1; state->update = TRUE; } @@ -830,8 +846,12 @@ static void menu_refilter ( MenuState *state ) } state->filtered_lines = state->num_lines; } - - state->selected = MIN ( state->selected, state->filtered_lines - 1 ); + if ( state->filtered_lines > 0 ) { + state->selected = MIN ( state->selected, state->filtered_lines - 1 ); + } + else { + state->selected = 0; + } if ( config.auto_select == TRUE && state->filtered_lines == 1 && state->num_lines > 1 ) { *( state->selected_line ) = state->line_map[state->selected]; @@ -1510,7 +1530,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select } // This is needed for letting the Input Method handle combined keys. // E.g. `e into รจ - if ( XFilterEvent ( &ev, main_window) ) { + if ( XFilterEvent ( &ev, main_window ) ) { continue; } diff --git a/source/textbox.c b/source/textbox.c index 6e1679a5..06fa46b6 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -575,7 +575,8 @@ int textbox_keypress ( textbox *tb, XIC xic, XEvent *ev ) } // Filter When alt/ctrl/etc is pressed do not accept the character. // Ignore others (numlock, shift,..). - else if ( !iscntrl ( *pad ) && 0 == ( ev->xkey.state & ~( ModeSwitchMask | NumlockMask | ( 1 << 12 ) | ( 1 << 13 ) | ShiftMask | LockMask ) ) ) { + else if ( !iscntrl ( *pad ) && 0 == + ( ev->xkey.state & ~( ModeSwitchMask | NumlockMask | ( 1 << 12 ) | ( 1 << 13 ) | ShiftMask | LockMask ) ) ) { textbox_insert ( tb, tb->cursor, pad ); textbox_cursor_inc ( tb ); return 1; diff --git a/source/x11-helper.c b/source/x11-helper.c index cda8c674..3850cb9f 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -57,8 +57,8 @@ Atom netatoms[NUM_NETATOMS]; const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) }; // Mask indicating num-lock. -unsigned int NumlockMask = 0; -unsigned int ModeSwitchMask = 0; +unsigned int NumlockMask = 0; +unsigned int ModeSwitchMask = 0; extern Colormap map; @@ -370,7 +370,7 @@ static void x11_figure_out_numlock_mask ( Display *display ) { XModifierKeymap *modmap = XGetModifierMapping ( display ); KeyCode kc = XKeysymToKeycode ( display, XK_Num_Lock ); - KeyCode kc_ms = XKeysymToKeycode ( display, XK_Mode_switch); + KeyCode kc_ms = XKeysymToKeycode ( display, XK_Mode_switch ); for ( int i = 0; i < 8; i++ ) { for ( int j = 0; j < ( int ) modmap->max_keypermod; j++ ) { if ( modmap->modifiermap[i * modmap->max_keypermod + j] == kc ) { diff --git a/test/run_issue_275.sh b/test/run_issue_275.sh index 7c4d5703..2e2c1bcd 100755 --- a/test/run_issue_275.sh +++ b/test/run_issue_275.sh @@ -14,6 +14,8 @@ sleep 0.4 xdotool key 'e' sleep 0.4 xdotool key End +sleep 0.4 +xdotool key Return # Get result, kill xvfb wait ${RPID}