diff options
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/keyboard.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 5c1e7ae6..c1b53237 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -32,6 +32,7 @@ static void state_erase_key(struct sway_shortcut_state *state, | |||
32 | state->pressed_keys[state->npressed] = 0; | 32 | state->pressed_keys[state->npressed] = 0; |
33 | state->pressed_keycodes[state->npressed] = 0; | 33 | state->pressed_keycodes[state->npressed] = 0; |
34 | } | 34 | } |
35 | state->current_key = 0; | ||
35 | } | 36 | } |
36 | 37 | ||
37 | /** | 38 | /** |
@@ -56,6 +57,7 @@ static void state_add_key(struct sway_shortcut_state *state, | |||
56 | state->pressed_keys[i] = key_id; | 57 | state->pressed_keys[i] = key_id; |
57 | state->pressed_keycodes[i] = keycode; | 58 | state->pressed_keycodes[i] = keycode; |
58 | state->npressed++; | 59 | state->npressed++; |
60 | state->current_key = key_id; | ||
59 | } | 61 | } |
60 | 62 | ||
61 | /** | 63 | /** |
@@ -94,7 +96,6 @@ static void get_active_binding(const struct sway_shortcut_state *state, | |||
94 | bool binding_release = binding->flags & BINDING_RELEASE; | 96 | bool binding_release = binding->flags & BINDING_RELEASE; |
95 | 97 | ||
96 | if (modifiers ^ binding->modifiers || | 98 | if (modifiers ^ binding->modifiers || |
97 | state->npressed != (size_t)binding->keys->length || | ||
98 | release != binding_release || | 99 | release != binding_release || |
99 | locked > binding_locked || | 100 | locked > binding_locked || |
100 | (strcmp(binding->input, input) != 0 && | 101 | (strcmp(binding->input, input) != 0 && |
@@ -102,13 +103,22 @@ static void get_active_binding(const struct sway_shortcut_state *state, | |||
102 | continue; | 103 | continue; |
103 | } | 104 | } |
104 | 105 | ||
105 | bool match = true; | 106 | bool match = false; |
106 | for (size_t j = 0; j < state->npressed; j++) { | 107 | if (state->npressed == (size_t)binding->keys->length) { |
107 | uint32_t key = *(uint32_t *)binding->keys->items[j]; | 108 | match = true; |
108 | if (key != state->pressed_keys[j]) { | 109 | for (size_t j = 0; j < state->npressed; j++) { |
109 | match = false; | 110 | uint32_t key = *(uint32_t *)binding->keys->items[j]; |
110 | break; | 111 | if (key != state->pressed_keys[j]) { |
112 | match = false; | ||
113 | break; | ||
114 | } | ||
111 | } | 115 | } |
116 | } else if (binding->keys->length == 1) { | ||
117 | /* | ||
118 | * If no multiple-key binding has matched, try looking for | ||
119 | * single-key bindings that match the newly-pressed key. | ||
120 | */ | ||
121 | match = state->current_key == *(uint32_t *)binding->keys->items[0]; | ||
112 | } | 122 | } |
113 | if (!match) { | 123 | if (!match) { |
114 | continue; | 124 | continue; |