Fix #67 Allow alt-<num> to switch between modis

This commit is contained in:
QC 2014-07-21 23:19:45 +02:00
parent 60e23568d8
commit bd4aa3d2fa
5 changed files with 23 additions and 1 deletions

View File

@ -52,7 +52,8 @@ typedef enum
/** Custom (non-matched) input was entered. */
MENU_CUSTOM_INPUT = -3,
/** User wanted to delete entry from history. */
MENU_ENTRY_DELETE = -4
MENU_ENTRY_DELETE = -4,
MENU_QUICK_SWITCH = -5,
} MenuReturn;

View File

@ -1373,6 +1373,12 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
break;
}
}
else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) &&
key >= XK_1 && key <= XK_9 ) {
*selected_line = ( key - XK_1 );
retv = MENU_QUICK_SWITCH;
break;
}
int rc = textbox_keypress ( text, &ev );
@ -1653,6 +1659,9 @@ SwitcherMode run_switcher_window ( char **input, void *data )
if ( mretv == MENU_NEXT ) {
retv = NEXT_DIALOG;
}
else if ( mretv == MENU_QUICK_SWITCH ) {
retv = selected_line;
}
else if ( mretv == MENU_OK && list[selected_line] ) {
#ifdef HAVE_I3_IPC_H
@ -1726,6 +1735,9 @@ static void run_switcher ( int do_fork, SwitcherMode mode )
else if ( retv == RELOAD_DIALOG ) {
// do nothing.
}
else if ( retv < DMENU_DIALOG ) {
mode = ( retv ) % num_switchers;
}
else {
mode = retv;
}

View File

@ -218,6 +218,9 @@ SwitcherMode run_switcher_dialog ( char **input, void *data )
if ( mretv == MENU_NEXT ) {
retv = NEXT_DIALOG;
}
else if ( mretv == MENU_QUICK_SWITCH ) {
retv = selected_line;
}
else if ( mretv == MENU_OK && cmd_list[selected_line] != NULL ) {
exec_cmd ( cmd_list[selected_line], shift );
}

View File

@ -134,6 +134,9 @@ SwitcherMode script_switcher_dialog ( char **input, void *data )
if ( mretv == MENU_NEXT ) {
retv = NEXT_DIALOG;
}
else if ( mretv == MENU_QUICK_SWITCH ) {
retv = selected_line;
}
else if ( mretv == MENU_OK && list[selected_line] != NULL ) {
new_list = execute_executor ( options, list[selected_line], &new_length );
}

View File

@ -235,6 +235,9 @@ SwitcherMode ssh_switcher_dialog ( char **input, void *data )
if ( mretv == MENU_NEXT ) {
retv = NEXT_DIALOG;
}
else if ( mretv == MENU_QUICK_SWITCH ) {
retv = selected_line;
}
else if ( mretv == MENU_OK && cmd_list[selected_line] != NULL ) {
exec_ssh ( cmd_list[selected_line] );
}