mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 00:27:36 +00:00
view: Store modstate on keypress event
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
990914d20f
commit
590e61b417
3 changed files with 29 additions and 27 deletions
|
@ -110,7 +110,7 @@ void textbox_draw ( textbox *tb, cairo_t *draw );
|
|||
*
|
||||
* @returns if the key was handled (1), unhandled(0) or handled and return was pressed (-1)
|
||||
*/
|
||||
int textbox_keypress ( textbox *tb, xcb_key_press_event_t *ev, char *pad, int pad_len, xkb_keysym_t key );
|
||||
int textbox_keypress ( textbox *tb, char *pad, int pad_len, unsigned int modstate, xkb_keysym_t key );
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
|
|
|
@ -533,7 +533,7 @@ static void textbox_cursor_del_word ( textbox *tb )
|
|||
// 0 = unhandled
|
||||
// 1 = handled
|
||||
// -1 = handled and return pressed (finished)
|
||||
int textbox_keypress ( textbox *tb, xcb_key_press_event_t *ev, char *pad, int pad_len, xkb_keysym_t key )
|
||||
int textbox_keypress ( textbox *tb, char *pad, int pad_len, unsigned int modstate, xkb_keysym_t key )
|
||||
{
|
||||
if ( !( tb->flags & TB_EDITABLE ) ) {
|
||||
return 0;
|
||||
|
@ -542,67 +542,67 @@ int textbox_keypress ( textbox *tb, xcb_key_press_event_t *ev, char *pad, int pa
|
|||
tb->blink = 2;
|
||||
if ( key != XKB_KEY_NoSymbol ) {
|
||||
// Left or Ctrl-b
|
||||
if ( abe_test_action ( MOVE_CHAR_BACK, ev->state, key ) ) {
|
||||
if ( abe_test_action ( MOVE_CHAR_BACK, modstate, key ) ) {
|
||||
textbox_cursor_dec ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Right or Ctrl-F
|
||||
else if ( abe_test_action ( MOVE_CHAR_FORWARD, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_CHAR_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_inc ( tb );
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Ctrl-U: Kill from the beginning to the end of the line.
|
||||
else if ( abe_test_action ( CLEAR_LINE, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( CLEAR_LINE, modstate, key ) ) {
|
||||
textbox_text ( tb, "" );
|
||||
return 1;
|
||||
}
|
||||
// Ctrl-A
|
||||
else if ( abe_test_action ( MOVE_FRONT, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_FRONT, modstate, key ) ) {
|
||||
textbox_cursor ( tb, 0 );
|
||||
return 2;
|
||||
}
|
||||
// Ctrl-E
|
||||
else if ( abe_test_action ( MOVE_END, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_END, modstate, key ) ) {
|
||||
textbox_cursor_end ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Ctrl-Alt-h
|
||||
else if ( abe_test_action ( REMOVE_WORD_BACK, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_WORD_BACK, modstate, key ) ) {
|
||||
textbox_cursor_bkspc_word ( tb );
|
||||
return 1;
|
||||
}
|
||||
// Ctrl-Alt-d
|
||||
else if ( abe_test_action ( REMOVE_WORD_FORWARD, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_WORD_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_del_word ( tb );
|
||||
return 1;
|
||||
} // Delete or Ctrl-D
|
||||
else if ( abe_test_action ( REMOVE_CHAR_FORWARD, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_CHAR_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_del ( tb );
|
||||
return 1;
|
||||
}
|
||||
// Alt-B
|
||||
else if ( abe_test_action ( MOVE_WORD_BACK, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_WORD_BACK, modstate, key ) ) {
|
||||
textbox_cursor_dec_word ( tb );
|
||||
return 2;
|
||||
}
|
||||
// Alt-F
|
||||
else if ( abe_test_action ( MOVE_WORD_FORWARD, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( MOVE_WORD_FORWARD, modstate, key ) ) {
|
||||
textbox_cursor_inc_word ( tb );
|
||||
return 2;
|
||||
}
|
||||
// BackSpace, Ctrl-h
|
||||
else if ( abe_test_action ( REMOVE_CHAR_BACK, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( REMOVE_CHAR_BACK, modstate, key ) ) {
|
||||
textbox_cursor_bkspc ( tb );
|
||||
return 1;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_CUSTOM, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_CUSTOM, modstate, key ) ) {
|
||||
return -2;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY_CONTINUE, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY_CONTINUE, modstate, key ) ) {
|
||||
return -3;
|
||||
}
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY, ev->state, key ) ) {
|
||||
else if ( abe_test_action ( ACCEPT_ENTRY, modstate, key ) ) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1328,41 +1328,43 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
|||
len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
|
||||
}
|
||||
|
||||
unsigned int modstate = xkpe->state;
|
||||
|
||||
if ( key != XKB_KEY_NoSymbol ) {
|
||||
// Handling of paste
|
||||
if ( abe_test_action ( PASTE_PRIMARY, xkpe->state, key ) ) {
|
||||
if ( abe_test_action ( PASTE_PRIMARY, modstate, key ) ) {
|
||||
XConvertSelection ( display, XA_PRIMARY, netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window, CurrentTime );
|
||||
}
|
||||
else if ( abe_test_action ( PASTE_SECONDARY, xkpe->state, key ) ) {
|
||||
else if ( abe_test_action ( PASTE_SECONDARY, modstate, key ) ) {
|
||||
XConvertSelection ( display, netatoms[CLIPBOARD], netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window,
|
||||
CurrentTime );
|
||||
}
|
||||
if ( abe_test_action ( SCREENSHOT, xkpe->state, key ) ) {
|
||||
if ( abe_test_action ( SCREENSHOT, modstate, key ) ) {
|
||||
menu_capture_screenshot ( );
|
||||
break;
|
||||
}
|
||||
if ( abe_test_action ( TOGGLE_SORT, xkpe->state, key ) ) {
|
||||
if ( abe_test_action ( TOGGLE_SORT, modstate, key ) ) {
|
||||
config.levenshtein_sort = !config.levenshtein_sort;
|
||||
state->refilter = TRUE;
|
||||
state->update = TRUE;
|
||||
textbox_text ( state->case_indicator, get_matching_state () );
|
||||
break;
|
||||
}
|
||||
else if ( abe_test_action ( MODE_PREVIOUS, xkpe->state, key ) ) {
|
||||
else if ( abe_test_action ( MODE_PREVIOUS, modstate, key ) ) {
|
||||
state->retv = MENU_PREVIOUS;
|
||||
( state->selected_line ) = 0;
|
||||
state->quit = TRUE;
|
||||
break;
|
||||
}
|
||||
// Menu navigation.
|
||||
else if ( abe_test_action ( MODE_NEXT, xkpe->state, key ) ) {
|
||||
else if ( abe_test_action ( MODE_NEXT, modstate, key ) ) {
|
||||
state->retv = MENU_NEXT;
|
||||
( state->selected_line ) = 0;
|
||||
state->quit = TRUE;
|
||||
break;
|
||||
}
|
||||
// Toggle case sensitivity.
|
||||
else if ( abe_test_action ( TOGGLE_CASE_SENSITIVITY, xkpe->state, key ) ) {
|
||||
else if ( abe_test_action ( TOGGLE_CASE_SENSITIVITY, modstate, key ) ) {
|
||||
config.case_sensitive = !config.case_sensitive;
|
||||
( state->selected_line ) = 0;
|
||||
state->refilter = TRUE;
|
||||
|
@ -1371,7 +1373,7 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
|||
break;
|
||||
}
|
||||
// Special delete entry command.
|
||||
else if ( abe_test_action ( DELETE_ENTRY, xkpe->state, key ) ) {
|
||||
else if ( abe_test_action ( DELETE_ENTRY, modstate, key ) ) {
|
||||
if ( state->selected < state->filtered_lines ) {
|
||||
( state->selected_line ) = state->line_map[state->selected];
|
||||
state->retv = MENU_ENTRY_DELETE;
|
||||
|
@ -1380,7 +1382,7 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
|||
}
|
||||
}
|
||||
for ( unsigned int a = CUSTOM_1; a <= CUSTOM_19; a++ ) {
|
||||
if ( abe_test_action ( a, xkpe->state, key ) ) {
|
||||
if ( abe_test_action ( a, modstate, key ) ) {
|
||||
state->selected_line = UINT32_MAX;
|
||||
if ( state->selected < state->filtered_lines ) {
|
||||
( state->selected_line ) = state->line_map[state->selected];
|
||||
|
@ -1390,7 +1392,7 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ( rofi_view_keyboard_navigation ( state, key, xkpe->state ) ) {
|
||||
if ( rofi_view_keyboard_navigation ( state, key, modstate ) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1400,7 +1402,7 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
|
|||
break;
|
||||
}
|
||||
|
||||
int rc = textbox_keypress ( state->text, xkpe, pad, len, key );
|
||||
int rc = textbox_keypress ( state->text, pad, len, modstate, key );
|
||||
// Row is accepted.
|
||||
if ( rc < 0 ) {
|
||||
int shift = ( ( xkpe->state & ShiftMask ) == ShiftMask );
|
||||
|
|
Loading…
Reference in a new issue