diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-02-04 16:25:04 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-02-04 16:25:04 +0100 |
commit | 531f3f884ac87b7a2f8d5494acbe255deee20bed (patch) | |
tree | 476fda936bb68ebe56cb6b219becd299fa700432 /source/dialogs | |
parent | c173d9d7075f71d7c71abc2def05de07645e9911 (diff) | |
parent | 69b88caac5dc1dcac5227850c6aa6893a0eac449 (diff) |
Merge remote-tracking branch 'origin/master' into glib-loop
Diffstat (limited to 'source/dialogs')
-rw-r--r-- | source/dialogs/dmenu.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index cb59f853..04f54f7b 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -427,25 +427,28 @@ int dmenu_switcher_dialog ( void ) * Select item mode. */ restart = 1; - 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; - } - else if ( ( mretv & MENU_CANCEL ) == MENU_CANCEL ) { + // Skip if no valid item is selected. + if ( ( mretv & MENU_CANCEL ) == MENU_CANCEL ) { // In no custom mode we allow canceling. 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; } // We normally do not want to restart the loop. restart = FALSE; // 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 ); if ( ( mretv & MENU_SHIFT ) ) { restart = TRUE; |