mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Rasi patch, allowing special keys, modifying return value.
In dmenu pressing alt-[1-9 will return the selected entry and set the return value to the pressed number.
This commit is contained in:
parent
a974db887a
commit
8d4e1ee8fa
9 changed files with 42 additions and 20 deletions
|
@ -45,21 +45,23 @@ typedef const char * ( *get_display_value )( unsigned int selected_line, void *d
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
/** Entry is selected. */
|
/** Entry is selected. */
|
||||||
MENU_OK = 0x1,
|
MENU_OK = 0x0010000,
|
||||||
/** User canceled the operation. (e.g. pressed escape) */
|
/** User canceled the operation. (e.g. pressed escape) */
|
||||||
MENU_CANCEL = 0x2,
|
MENU_CANCEL = 0x0020000,
|
||||||
/** User requested a mode switch */
|
/** User requested a mode switch */
|
||||||
MENU_NEXT = 0x4,
|
MENU_NEXT = 0x0040000,
|
||||||
/** Custom (non-matched) input was entered. */
|
/** Custom (non-matched) input was entered. */
|
||||||
MENU_CUSTOM_INPUT = 0x8,
|
MENU_CUSTOM_INPUT = 0x0080000,
|
||||||
/** User wanted to delete entry from history. */
|
/** User wanted to delete entry from history. */
|
||||||
MENU_ENTRY_DELETE = 0x10,
|
MENU_ENTRY_DELETE = 0x00100000,
|
||||||
/** User wants to jump to another switcher. */
|
/** User wants to jump to another switcher. */
|
||||||
MENU_QUICK_SWITCH = 0x20,
|
MENU_QUICK_SWITCH = 0x00200000,
|
||||||
/** Go to the previous menu. */
|
/** Go to the previous menu. */
|
||||||
MENU_PREVIOUS = 0x40,
|
MENU_PREVIOUS = 0x00400000,
|
||||||
/** Modifiers */
|
/** Modifiers */
|
||||||
MENU_SHIFT = 0x1000
|
MENU_SHIFT = 0x10000000,
|
||||||
|
/** Mask */
|
||||||
|
MENU_LOWER_MASK = 0x0000FFFF
|
||||||
} MenuReturn;
|
} MenuReturn;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,19 @@ int dmenu_switcher_dialog ( char **input )
|
||||||
}
|
}
|
||||||
retv = TRUE;
|
retv = TRUE;
|
||||||
}
|
}
|
||||||
|
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||||
|
if ( number_mode ) {
|
||||||
|
fprintf ( stdout, "%d", selected_line );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fputs ( list[selected_line], stdout );
|
||||||
|
}
|
||||||
|
fputc ( '\n', stdout );
|
||||||
|
fflush ( stdout );
|
||||||
|
|
||||||
|
restart = FALSE;
|
||||||
|
retv = -( mretv & MENU_LOWER_MASK ) - 1;
|
||||||
|
}
|
||||||
} while ( restart );
|
} while ( restart );
|
||||||
|
|
||||||
g_strfreev ( list );
|
g_strfreev ( list );
|
||||||
|
|
|
@ -305,7 +305,7 @@ static SwitcherMode run_mode_result ( int mretv, char **input, unsigned int sele
|
||||||
retv = PREVIOUS_DIALOG;
|
retv = PREVIOUS_DIALOG;
|
||||||
}
|
}
|
||||||
else if ( mretv & MENU_QUICK_SWITCH ) {
|
else if ( mretv & MENU_QUICK_SWITCH ) {
|
||||||
retv = selected_line;
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||||
exec_cmd ( rmpd->cmd_list[selected_line], shift );
|
exec_cmd ( rmpd->cmd_list[selected_line], shift );
|
||||||
|
|
|
@ -131,7 +131,7 @@ static SwitcherMode script_mode_result ( int mretv, char **input, unsigned int s
|
||||||
retv = PREVIOUS_DIALOG;
|
retv = PREVIOUS_DIALOG;
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||||
retv = selected_line;
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||||
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line], &new_length );
|
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line], &new_length );
|
||||||
|
|
|
@ -295,7 +295,7 @@ static SwitcherMode ssh_mode_result ( int mretv, char **input, unsigned int sele
|
||||||
retv = PREVIOUS_DIALOG;
|
retv = PREVIOUS_DIALOG;
|
||||||
}
|
}
|
||||||
else if ( mretv & MENU_QUICK_SWITCH ) {
|
else if ( mretv & MENU_QUICK_SWITCH ) {
|
||||||
retv = selected_line;
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||||
exec_ssh ( rmpd->cmd_list[selected_line] );
|
exec_ssh ( rmpd->cmd_list[selected_line] );
|
||||||
|
|
|
@ -478,8 +478,8 @@ static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input,
|
||||||
else if ( mretv & MENU_PREVIOUS ) {
|
else if ( mretv & MENU_PREVIOUS ) {
|
||||||
retv = PREVIOUS_DIALOG;
|
retv = PREVIOUS_DIALOG;
|
||||||
}
|
}
|
||||||
else if ( mretv == MENU_QUICK_SWITCH ) {
|
else if ( ( mretv & MENU_QUICK_SWITCH ) == MENU_QUICK_SWITCH ) {
|
||||||
retv = selected_line;
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && rmpd->cmd_list[selected_line] ) {
|
else if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && rmpd->cmd_list[selected_line] ) {
|
||||||
if ( rmpd->config_i3_mode ) {
|
if ( rmpd->config_i3_mode ) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ DefaultBinding bindings[NUM_ABE] =
|
||||||
.keybinding = "BackSpace,Control+h",
|
.keybinding = "BackSpace,Control+h",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = ACCEPT_ENTRY,
|
.id = ACCEPT_ENTRY,
|
||||||
.name = "kb-accept-entry",
|
.name = "kb-accept-entry",
|
||||||
.keybinding = "Control+j,Control+m,Return,KP_Enter",
|
.keybinding = "Control+j,Control+m,Return,KP_Enter",
|
||||||
},
|
},
|
||||||
|
|
|
@ -686,8 +686,8 @@ static void menu_mouse_navigation ( MenuState *state, XButtonEvent *xbe )
|
||||||
else {
|
else {
|
||||||
for ( unsigned int i = 0; config.sidebar_mode == TRUE && i < num_switchers; i++ ) {
|
for ( unsigned int i = 0; config.sidebar_mode == TRUE && i < num_switchers; i++ ) {
|
||||||
if ( switchers[i]->tb->window == ( xbe->window ) ) {
|
if ( switchers[i]->tb->window == ( xbe->window ) ) {
|
||||||
*( state->selected_line ) = i;
|
*( state->selected_line ) = 0;
|
||||||
state->retv = MENU_QUICK_SWITCH;
|
state->retv = MENU_QUICK_SWITCH | ( i & MENU_LOWER_MASK );
|
||||||
state->quit = TRUE;
|
state->quit = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1180,9 +1180,13 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
// Switcher short-cut
|
// Switcher short-cut
|
||||||
else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) &&
|
else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) &&
|
||||||
key >= XK_1 && key <= XK_9 ) {
|
key >= XK_1 && key <= XK_9 ) {
|
||||||
*( state.selected_line ) = ( key - XK_1 );
|
if ( state.selected < state.filtered_lines ) {
|
||||||
state.retv = MENU_QUICK_SWITCH;
|
*( state.selected_line ) = state.line_map[state.selected];
|
||||||
state.quit = TRUE;
|
}
|
||||||
|
//*( state.selected_line ) = ( key - XK_1 );
|
||||||
|
unsigned int data = ( key - XK_1 );
|
||||||
|
state.retv = MENU_QUICK_SWITCH | ( data & MENU_LOWER_MASK );
|
||||||
|
state.quit = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Special delete entry command.
|
// Special delete entry command.
|
||||||
|
@ -1759,6 +1763,9 @@ int main ( int argc, char *argv[] )
|
||||||
if ( retv == FALSE ) {
|
if ( retv == FALSE ) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
else if ( retv < 0 ) {
|
||||||
|
return -retv;
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ int window_send_message ( Display *display, Window target,
|
||||||
|
|
||||||
int take_keyboard ( Display *display, Window w )
|
int take_keyboard ( Display *display, Window w )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < 500; i++) {
|
for ( int i = 0; i < 500; i++ ) {
|
||||||
if ( XGrabKeyboard ( display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime ) == GrabSuccess ) {
|
if ( XGrabKeyboard ( display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime ) == GrabSuccess ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue