diff options
author | emersion <contact@emersion.fr> | 2018-06-02 09:18:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-02 09:18:07 +0100 |
commit | 2d480e754e8287ba747faf1b21d8ecb927d565a1 (patch) | |
tree | cf71dc112c1b4acb944073d93b73f76ee957ceac /include | |
parent | Merge pull request #2088 from RyanDwyer/fix-floating-border-pixel (diff) | |
parent | Style fix, redundant entry removal, fix extra keysym delete (diff) | |
download | sway-2d480e754e8287ba747faf1b21d8ecb927d565a1.tar.gz sway-2d480e754e8287ba747faf1b21d8ecb927d565a1.tar.zst sway-2d480e754e8287ba747faf1b21d8ecb927d565a1.zip |
Merge pull request #2080 from frsfnrrg/keyboard-remodeling
Reduce work duplication in keyboard and binding code
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/input/keyboard.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h index 8ec3eb35..e99a54b1 100644 --- a/include/sway/input/keyboard.h +++ b/include/sway/input/keyboard.h | |||
@@ -3,7 +3,26 @@ | |||
3 | 3 | ||
4 | #include "sway/input/seat.h" | 4 | #include "sway/input/seat.h" |
5 | 5 | ||
6 | #define SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP 32 | 6 | #define SWAY_KEYBOARD_PRESSED_KEYS_CAP 32 |
7 | |||
8 | struct sway_shortcut_state { | ||
9 | /** | ||
10 | * A list of pressed key ids (either keysyms or keycodes), | ||
11 | * including duplicates when different keycodes produce the same key id. | ||
12 | * | ||
13 | * Each key id is associated with the keycode (in `pressed_keycodes`) | ||
14 | * whose press generated it, so that the key id can be removed on | ||
15 | * keycode release without recalculating the transient link between | ||
16 | * keycode and key id at the time of the key press. | ||
17 | */ | ||
18 | uint32_t pressed_keys[SWAY_KEYBOARD_PRESSED_KEYS_CAP]; | ||
19 | /** | ||
20 | * The list of keycodes associated to currently pressed key ids, | ||
21 | * including duplicates when a keycode generates multiple key ids. | ||
22 | */ | ||
23 | uint32_t pressed_keycodes[SWAY_KEYBOARD_PRESSED_KEYS_CAP]; | ||
24 | int last_key_index; | ||
25 | }; | ||
7 | 26 | ||
8 | struct sway_keyboard { | 27 | struct sway_keyboard { |
9 | struct sway_seat_device *seat_device; | 28 | struct sway_seat_device *seat_device; |
@@ -13,11 +32,11 @@ struct sway_keyboard { | |||
13 | struct wl_listener keyboard_key; | 32 | struct wl_listener keyboard_key; |
14 | struct wl_listener keyboard_modifiers; | 33 | struct wl_listener keyboard_modifiers; |
15 | 34 | ||
16 | xkb_keysym_t pressed_keysyms_translated[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP]; | 35 | struct sway_shortcut_state state_keysyms_translated; |
17 | uint32_t modifiers_translated; | 36 | struct sway_shortcut_state state_keysyms_raw; |
18 | 37 | struct sway_shortcut_state state_keycodes; | |
19 | xkb_keysym_t pressed_keysyms_raw[SWAY_KEYBOARD_PRESSED_KEYSYMS_CAP]; | 38 | struct sway_binding *held_binding; |
20 | uint32_t modifiers_raw; | 39 | uint32_t last_modifiers; |
21 | }; | 40 | }; |
22 | 41 | ||
23 | struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, | 42 | struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, |