diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-12 15:19:23 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-12 15:19:23 -0500 |
commit | 34277207fd63b57ec8170f011a4115ef11c8ab0d (patch) | |
tree | 410240d8afd230219c0f0aeaf8c41b329925c880 /wayland | |
parent | Implement invoking `sway` as IPC client (diff) | |
download | sway-34277207fd63b57ec8170f011a4115ef11c8ab0d.tar.gz sway-34277207fd63b57ec8170f011a4115ef11c8ab0d.tar.zst sway-34277207fd63b57ec8170f011a4115ef11c8ab0d.zip |
Pass keys along from wayland backend to clients
Diffstat (limited to 'wayland')
-rw-r--r-- | wayland/registry.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/wayland/registry.c b/wayland/registry.c index 6c290185..89756292 100644 --- a/wayland/registry.c +++ b/wayland/registry.c | |||
@@ -133,18 +133,36 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, | |||
133 | xkb_keysym_t sym = xkb_state_key_get_one_sym(registry->input->xkb.state, key + 8); | 133 | xkb_keysym_t sym = xkb_state_key_get_one_sym(registry->input->xkb.state, key + 8); |
134 | registry->input->sym = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? sym : XKB_KEY_NoSymbol); | 134 | registry->input->sym = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? sym : XKB_KEY_NoSymbol); |
135 | registry->input->code = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? key + 8 : 0); | 135 | registry->input->code = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? key + 8 : 0); |
136 | uint32_t codepoint = xkb_state_key_get_utf32(registry->input->xkb.state, registry->input->code); | ||
136 | if (registry->input->notify) { | 137 | if (registry->input->notify) { |
137 | registry->input->notify(state, sym, key); | 138 | registry->input->notify(state, sym, key, codepoint); |
138 | } | 139 | } |
139 | } | 140 | } |
140 | 141 | ||
141 | static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, | 142 | static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, |
142 | uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, | 143 | uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, |
143 | uint32_t mods_locked, uint32_t group) { | 144 | uint32_t mods_locked, uint32_t group) { |
145 | struct registry *registry = data; | ||
146 | |||
147 | if (!registry->input->xkb.keymap) { | ||
148 | return; | ||
149 | } | ||
150 | |||
151 | xkb_state_update_mask(registry->input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); | ||
152 | xkb_mod_mask_t mask = xkb_state_serialize_mods(registry->input->xkb.state, | ||
153 | XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); | ||
154 | |||
155 | registry->input->modifiers = 0; | ||
156 | for (uint32_t i = 0; i < MASK_LAST; ++i) { | ||
157 | if (mask & registry->input->xkb.masks[i]) { | ||
158 | registry->input->modifiers |= XKB_MODS[i]; | ||
159 | } | ||
160 | } | ||
144 | } | 161 | } |
145 | 162 | ||
146 | static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *keyboard, | 163 | static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *keyboard, |
147 | int32_t rate, int32_t delay) { | 164 | int32_t rate, int32_t delay) { |
165 | // this space intentionally left blank | ||
148 | } | 166 | } |
149 | 167 | ||
150 | static const struct wl_keyboard_listener keyboard_listener = { | 168 | static const struct wl_keyboard_listener keyboard_listener = { |