aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-11-28 15:36:14 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-08 17:03:39 +0000
commit71606009fda541132de0f12c2b68b9e69c5bc7f7 (patch)
tree9e312d9e079b4fb4686020f232f90b04a301064a
parentinstall: add UTF-8 locate to runtime deps (diff)
input: don’t ignore key release events
Before this, key release events stopped the repeat timer, and then returned. Now, we run through the entire function. Most things are still only done on key press events. But, the goal here is to get to the keyboard protocol functions (and the kitty protocol in particular), and call them on release events too. This is in preparation for the kitty protocol mode 0b10, report event types.
-rw-r--r--input.c105
1 files changed, 62 insertions, 43 deletions
diff --git a/input.c b/input.c
index 055c0fc8..117f4e08 100644
--- a/input.c
+++ b/input.c
@@ -1026,6 +1026,9 @@ static bool
legacy_kbd_protocol(struct seat *seat, struct terminal *term,
const struct kbd_ctx *ctx)
{
+ if (ctx->key_state != WL_KEYBOARD_KEY_STATE_PRESSED)
+ return;
+
enum modifier keymap_mods = MOD_NONE;
keymap_mods |= seat->kbd.shift ? MOD_SHIFT : MOD_NONE;
keymap_mods |= seat->kbd.alt ? MOD_ALT : MOD_NONE;
@@ -1418,15 +1421,20 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
return;
}
- if (state == XKB_KEY_UP) {
+ const bool pressed = state == WL_KEYBOARD_KEY_STATE_PRESSED;
+ //const bool repeated = pressed && seat->kbd.repeat.dont_re_repeat;
+ const bool released = state == WL_KEYBOARD_KEY_STATE_RELEASED;
+
+ if (released)
stop_repeater(seat, key);
- return;
- }
- bool should_repeat = xkb_keymap_key_repeats(seat->kbd.xkb_keymap, key);
+ bool should_repeat =
+ pressed && xkb_keymap_key_repeats(seat->kbd.xkb_keymap, key);
+
xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->kbd.xkb_state, key);
- if (state == XKB_KEY_DOWN && term->conf->mouse.hide_when_typing &&
+ if (pressed && term->conf->mouse.hide_when_typing &&
+
/* TODO: better way to detect modifiers */
sym != XKB_KEY_Shift_L && sym != XKB_KEY_Shift_R &&
sym != XKB_KEY_Control_L && sym != XKB_KEY_Control_R &&
@@ -1443,7 +1451,8 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
enum xkb_compose_status compose_status = XKB_COMPOSE_NOTHING;
if (seat->kbd.xkb_compose_state != NULL) {
- xkb_compose_state_feed(seat->kbd.xkb_compose_state, sym);
+ if (pressed)
+ xkb_compose_state_feed(seat->kbd.xkb_compose_state, sym);
compose_status = xkb_compose_state_get_status(
seat->kbd.xkb_compose_state);
}
@@ -1464,18 +1473,26 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
size_t raw_count = xkb_keymap_key_get_syms_by_level(
seat->kbd.xkb_keymap, key, layout_idx, 0, &raw_syms);
- if (term->is_searching) {
- if (should_repeat)
- start_repeater(seat, key);
- search_input(
- seat, term, key, sym, bind_mods, bind_consumed, raw_syms, raw_count, serial);
- return;
- } else if (urls_mode_is_active(term)) {
- if (should_repeat)
- start_repeater(seat, key);
- urls_input(
- seat, term, key, sym, bind_mods, bind_consumed, raw_syms, raw_count, serial);
- return;
+ if (pressed) {
+ if (term->is_searching) {
+ if (should_repeat)
+ start_repeater(seat, key);
+
+ search_input(
+ seat, term, key, sym, bind_mods, bind_consumed,
+ raw_syms, raw_count, serial);
+ return;
+ }
+
+ else if (urls_mode_is_active(term)) {
+ if (should_repeat)
+ start_repeater(seat, key);
+
+ urls_input(
+ seat, term, key, sym, bind_mods, bind_consumed,
+ raw_syms, raw_count, serial);
+ return;
+ }
}
#if 0
@@ -1499,36 +1516,38 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
/*
* User configurable bindings
*/
- tll_foreach(seat->kbd.bindings.key, it) {
- const struct key_binding *bind = &it->item;
-
- /* Match translated symbol */
- if (bind->sym == sym &&
- bind->mods == (bind_mods & ~bind_consumed) &&
- execute_binding(
- seat, term, bind->action, bind->pipe_argv, serial))
- {
- goto maybe_repeat;
- }
+ if (pressed) {
+ tll_foreach(seat->kbd.bindings.key, it) {
+ const struct key_binding *bind = &it->item;
- if (bind->mods != bind_mods)
- continue;
-
- /* Match untranslated symbols */
- for (size_t i = 0; i < raw_count; i++) {
- if (bind->sym == raw_syms[i] && execute_binding(
+ /* Match translated symbol */
+ if (bind->sym == sym &&
+ bind->mods == (bind_mods & ~bind_consumed) &&
+ execute_binding(
seat, term, bind->action, bind->pipe_argv, serial))
{
goto maybe_repeat;
}
- }
- /* Match raw key code */
- tll_foreach(bind->key_codes, code) {
- if (code->item == key && execute_binding(
- seat, term, bind->action, bind->pipe_argv, serial))
- {
- goto maybe_repeat;
+ if (bind->mods != bind_mods)
+ continue;
+
+ /* Match untranslated symbols */
+ for (size_t i = 0; i < raw_count; i++) {
+ if (bind->sym == raw_syms[i] && execute_binding(
+ seat, term, bind->action, bind->pipe_argv, serial))
+ {
+ goto maybe_repeat;
+ }
+ }
+
+ /* Match raw key code */
+ tll_foreach(bind->key_codes, code) {
+ if (code->item == key && execute_binding(
+ seat, term, bind->action, bind->pipe_argv, serial))
+ {
+ goto maybe_repeat;
+ }
}
}
}
@@ -1590,7 +1609,7 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
? kitty_kbd_protocol(seat, term, &ctx)
: legacy_kbd_protocol(seat, term, &ctx);
- if (seat->kbd.xkb_compose_state != NULL)
+ if (seat->kbd.xkb_compose_state != NULL && pressed)
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
if (utf8 != buf)