From b23cd827cf934ef7f631b7c448e7afa4147c1936 Mon Sep 17 00:00:00 2001 From: frsfnrrg Date: Tue, 12 Jun 2018 10:37:47 -0400 Subject: Sort binding key lists Sort the list comprising the set of keys for the binding in ascending order. (Keyboard shortcuts depend only on the set of simultaneously pressed keys, not their order, so this change should have no external effect.) This simplifies comparisons between bindings. --- include/sway/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/sway/config.h b/include/sway/config.h index 81e9c382..e75b0664 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -30,7 +30,7 @@ struct sway_binding { bool release; bool locked; bool bindcode; - list_t *keys; + list_t *keys; // sorted in ascending order uint32_t modifiers; char *command; }; -- cgit v1.2.3 From ca061ba8bf94e1d09e1d912871841212778044ed Mon Sep 17 00:00:00 2001 From: frsfnrrg Date: Tue, 12 Jun 2018 11:07:11 -0400 Subject: Fix keyboard shortcut handling inconsistencies * Ensure that modifier keys are identified even when the next key does not produce a keysym. This requires that modifier change tracking be done for each sway_shortcut_state. * Permit regular and --release shortcuts on the same key combination. Distinct bindings are identified for press and release cases; note that the release binding needs to be identified for both key press and key release events. * Maintain ascending sort order for the shortcut state list, and keep track of the number of pressed key ids, for simpler (and hence faster) searching of the list of key bindings. * Move binding duplicate detection into get_active_binding to avoid duplicating error messages. --- include/sway/input/keyboard.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h index e99a54b1..6713398e 100644 --- a/include/sway/input/keyboard.h +++ b/include/sway/input/keyboard.h @@ -21,7 +21,9 @@ struct sway_shortcut_state { * including duplicates when a keycode generates multiple key ids. */ uint32_t pressed_keycodes[SWAY_KEYBOARD_PRESSED_KEYS_CAP]; - int last_key_index; + uint32_t last_keycode; + uint32_t last_raw_modifiers; + size_t npressed; }; struct sway_keyboard { @@ -36,7 +38,6 @@ struct sway_keyboard { struct sway_shortcut_state state_keysyms_raw; struct sway_shortcut_state state_keycodes; struct sway_binding *held_binding; - uint32_t last_modifiers; }; struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, -- cgit v1.2.3