mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-03 15:34:54 -05:00
Issue: #333, Check if row is selected, don't assume selected_line is valid.
This commit is contained in:
parent
fb4c0c085e
commit
b557c4df6e
4 changed files with 52 additions and 11 deletions
|
@ -222,6 +222,8 @@ test-x: ${bin_PROGRAMS}
|
||||||
$(top_srcdir)/test/run_test.sh 217 $(top_srcdir)/test/run_fuzzy_test.sh $(top_builddir)
|
$(top_srcdir)/test/run_test.sh 217 $(top_srcdir)/test/run_fuzzy_test.sh $(top_builddir)
|
||||||
echo "Test config dump"
|
echo "Test config dump"
|
||||||
$(top_srcdir)/test/run_test.sh 218 $(top_srcdir)/test/xr_config_test.sh $(top_builddir) $(top_srcdir)
|
$(top_srcdir)/test/run_test.sh 218 $(top_srcdir)/test/xr_config_test.sh $(top_builddir) $(top_srcdir)
|
||||||
|
echo "Test issue 333"
|
||||||
|
$(top_srcdir)/test/run_test.sh 221 $(top_srcdir)/test/run_ssue_333.sh $(top_builddir)
|
||||||
|
|
||||||
test-x1: ${bin_PROGRAMS}
|
test-x1: ${bin_PROGRAMS}
|
||||||
echo "Test dmenu-normal-window"
|
echo "Test dmenu-normal-window"
|
||||||
|
|
|
@ -426,25 +426,29 @@ int dmenu_switcher_dialog ( void )
|
||||||
* Select item mode.
|
* Select item mode.
|
||||||
*/
|
*/
|
||||||
restart = 1;
|
restart = 1;
|
||||||
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) {
|
// Skip if no valid item is selected.
|
||||||
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
if ( ( mretv & MENU_CANCEL ) == MENU_CANCEL ) {
|
||||||
retv = TRUE;
|
|
||||||
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
|
||||||
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
|
||||||
}
|
|
||||||
return retv;
|
|
||||||
}
|
|
||||||
else if ( ( mretv & MENU_CANCEL ) == MENU_CANCEL ) {
|
|
||||||
// In no custom mode we allow canceling.
|
// In no custom mode we allow canceling.
|
||||||
restart = ( find_arg ( "-only-match" ) >= 0 );
|
restart = ( find_arg ( "-only-match" ) >= 0 );
|
||||||
}
|
}
|
||||||
pd->selected_line = next_pos - 1;
|
else if ( pd->selected_line != UINT32_MAX ){
|
||||||
|
|
||||||
|
if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) {
|
||||||
|
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
||||||
|
retv = TRUE;
|
||||||
|
if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||||
|
retv = 10 + ( mretv & MENU_LOWER_MASK );
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
pd->selected_line = next_pos - 1;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We normally do not want to restart the loop.
|
// We normally do not want to restart the loop.
|
||||||
restart = FALSE;
|
restart = FALSE;
|
||||||
// Normal mode
|
// Normal mode
|
||||||
if ( ( mretv & MENU_OK ) && cmd_list[pd->selected_line] != NULL ) {
|
if ( ( mretv & MENU_OK ) && pd->selected_line != UINT32_MAX && cmd_list[pd->selected_line] != NULL ) {
|
||||||
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
|
||||||
if ( ( mretv & MENU_SHIFT ) ) {
|
if ( ( mretv & MENU_SHIFT ) ) {
|
||||||
restart = TRUE;
|
restart = TRUE;
|
||||||
|
|
|
@ -1379,6 +1379,7 @@ static void menu_mainloop_iter ( MenuState *state, XEvent *ev )
|
||||||
}
|
}
|
||||||
for ( unsigned int a = CUSTOM_1; a <= CUSTOM_19; a++ ) {
|
for ( unsigned int a = CUSTOM_1; a <= CUSTOM_19; a++ ) {
|
||||||
if ( abe_test_action ( a, ev->xkey.state, key ) ) {
|
if ( abe_test_action ( a, ev->xkey.state, key ) ) {
|
||||||
|
state->selected_line = UINT32_MAX;
|
||||||
if ( state->selected < state->filtered_lines ) {
|
if ( state->selected < state->filtered_lines ) {
|
||||||
( state->selected_line ) = state->line_map[state->selected];
|
( state->selected_line ) = state->line_map[state->selected];
|
||||||
}
|
}
|
||||||
|
@ -1403,6 +1404,7 @@ static void menu_mainloop_iter ( MenuState *state, XEvent *ev )
|
||||||
int shift = ( ( ev->xkey.state & ShiftMask ) == ShiftMask );
|
int shift = ( ( ev->xkey.state & ShiftMask ) == ShiftMask );
|
||||||
|
|
||||||
// If a valid item is selected, return that..
|
// If a valid item is selected, return that..
|
||||||
|
state->selected_line = UINT32_MAX;
|
||||||
if ( state->selected < state->filtered_lines ) {
|
if ( state->selected < state->filtered_lines ) {
|
||||||
( state->selected_line ) = state->line_map[state->selected];
|
( state->selected_line ) = state->line_map[state->selected];
|
||||||
if ( strlen ( state->text->text ) > 0 && rc == -2 ) {
|
if ( strlen ( state->text->text ) > 0 && rc == -2 ) {
|
||||||
|
|
33
test/run_issue333_test.sh
Executable file
33
test/run_issue333_test.sh
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# wait till it is up, run rofi with error message
|
||||||
|
rm -f output.txt
|
||||||
|
sleep 1;
|
||||||
|
echo -e -n "aap\nnoot\nmies" | rofi -dmenu -no-custom -kb-custom-1 F5 -kb-custom-2 "Control+a" > output.txt &
|
||||||
|
RPID=$!
|
||||||
|
|
||||||
|
# send enter.
|
||||||
|
sleep 5;
|
||||||
|
xdotool key 'q'
|
||||||
|
sleep 0.4
|
||||||
|
xdotool key Return
|
||||||
|
sleep 0.4
|
||||||
|
xdotool key F5
|
||||||
|
sleep 0.4
|
||||||
|
xdotool key "Control+a"
|
||||||
|
sleep 0.4
|
||||||
|
xdotool key Escape
|
||||||
|
|
||||||
|
# Get result, kill xvfb
|
||||||
|
wait ${RPID}
|
||||||
|
RETV=$?
|
||||||
|
OUTPUT=$(cat output.txt | tr '\n' ' ')
|
||||||
|
if [ "${OUTPUT}" != '' ]
|
||||||
|
then
|
||||||
|
echo "Got: '${OUTPUT}' expected nothing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ${RETV} != 1 ]
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Add table
Reference in a new issue