From 13eee4571c7323a2be8125f69f7b76ea2b985963 Mon Sep 17 00:00:00 2001 From: QC Date: Tue, 5 May 2015 19:30:43 +0200 Subject: [PATCH] Allow alt-1t/m9 be re-bound. --- include/keyb.h | 9 ++++++++ source/dialogs/dmenu.c | 2 +- source/keyb.c | 47 +++++++++++++++++++++++++++++++++++++- source/rofi.c | 51 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 98 insertions(+), 11 deletions(-) diff --git a/include/keyb.h b/include/keyb.h index 0aa8b860..b700bea6 100644 --- a/include/keyb.h +++ b/include/keyb.h @@ -23,6 +23,15 @@ typedef enum _KeyBindingAction MODE_PREVIOUS, TOGGLE_CASE_SENSITIVITY, DELETE_ENTRY, + CUSTOM_1, + CUSTOM_2, + CUSTOM_3, + CUSTOM_4, + CUSTOM_5, + CUSTOM_6, + CUSTOM_7, + CUSTOM_8, + CUSTOM_9, NUM_ABE } KeyBindingAction; diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 0dbe450e..151f38e7 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -203,7 +203,7 @@ int dmenu_switcher_dialog ( char **input ) fflush ( stdout ); restart = FALSE; - retv = 10+ ( mretv & MENU_LOWER_MASK ) ; + retv = 10 + ( mretv & MENU_LOWER_MASK ); } } while ( restart ); diff --git a/source/keyb.c b/source/keyb.c index d6165a1e..54c12ec6 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -136,7 +136,52 @@ DefaultBinding bindings[NUM_ABE] = .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" - } + }, + { + .id = CUSTOM_1, + .name = "kb-custom-1", + .keybinding = "Alt+1" + }, + { + .id = CUSTOM_2, + .name = "kb-custom-2", + .keybinding = "Alt+2" + }, + { + .id = CUSTOM_3, + .name = "kb-custom-3", + .keybinding = "Alt+3" + }, + { + .id = CUSTOM_4, + .name = "kb-custom-4", + .keybinding = "Alt+4" + }, + { + .id = CUSTOM_5, + .name = "kb-custom-5", + .keybinding = "Alt+5" + }, + { + .id = CUSTOM_6, + .name = "kb-custom-6", + .keybinding = "Alt+6" + }, + { + .id = CUSTOM_7, + .name = "kb-custom-7", + .keybinding = "Alt+7" + }, + { + .id = CUSTOM_8, + .name = "kb-custom-8", + .keybinding = "Alt+8" + }, + { + .id = CUSTOM_9, + .name = "kb-custom-9", + .keybinding = "Alt+9" + }, }; diff --git a/source/rofi.c b/source/rofi.c index 74f232ea..aea06999 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1177,15 +1177,48 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom textbox_hide ( state.case_indicator ); } } - // Switcher short-cut - else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) && - key >= XK_1 && key <= XK_9 ) { - if ( state.selected < state.filtered_lines ) { - *( state.selected_line ) = state.line_map[state.selected]; - } - //*( state.selected_line ) = ( key - XK_1 ); - unsigned int data = ( key - XK_1 ); - state.retv = MENU_QUICK_SWITCH | ( data & MENU_LOWER_MASK ); + else if ( abe_test_action ( CUSTOM_1, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 0 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_2, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 1 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_3, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 2 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_4, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 3 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_5, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 4 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_6, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 5 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_7, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 6 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_8, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 7 & MENU_LOWER_MASK ); + state.quit = TRUE; + break; + } + else if ( abe_test_action ( CUSTOM_9, ev.xkey.state, key ) ) { + state.retv = MENU_QUICK_SWITCH | ( 8 & MENU_LOWER_MASK ); state.quit = TRUE; break; }