summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2016-02-23 12:52:35 +0100
committerQuentin Glidic <sardemff7+git@sardemff7.net>2016-02-23 12:52:35 +0100
commit590e61b4174cf7dfac1ec9520c3a9a8b8a0bbf1d (patch)
treee7b156a4a7e0ebd3dcee217a690596293d84bfb3 /source
parent990914d20fc1a3bcd47955c934e2e1fffda38a6c (diff)
view: Store modstate on keypress event
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source')
-rw-r--r--source/textbox.c30
-rw-r--r--source/view.c24
2 files changed, 28 insertions, 26 deletions
diff --git a/source/textbox.c b/source/textbox.c
index b9f4b0a9..32e20ab3 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -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;
}
}
diff --git a/source/view.c b/source/view.c
index fd3d9227..42c4fc00 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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 );