aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/keyboard.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-14 14:06:35 -0500
committerLibravatar emersion <contact@emersion.fr>2019-01-14 20:15:23 +0100
commit2573606b60f0606860634b90749f734cd0e918b7 (patch)
tree35d9264a20a6e78134c8b39361123143f90b5e32 /sway/input/keyboard.c
parentCONTRIBUTING.md: mention tab width for line length (diff)
downloadsway-2573606b60f0606860634b90749f734cd0e918b7.tar.gz
sway-2573606b60f0606860634b90749f734cd0e918b7.tar.zst
sway-2573606b60f0606860634b90749f734cd0e918b7.zip
Disarm key repeat on reload
When resetting the keyboard during reload, disarm the key repeat on all keyboards since the bindings (and possibly keyboard) will be freed before the key repeat can go off.
Diffstat (limited to 'sway/input/keyboard.c')
-rw-r--r--sway/input/keyboard.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 46286410..2ea796a9 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -213,6 +213,16 @@ static size_t keyboard_keysyms_raw(struct sway_keyboard *keyboard,
213 keycode, layout_index, 0, keysyms); 213 keycode, layout_index, 0, keysyms);
214} 214}
215 215
216void sway_keyboard_disarm_key_repeat(struct sway_keyboard *keyboard) {
217 if (!keyboard) {
218 return;
219 }
220 keyboard->repeat_binding = NULL;
221 if (wl_event_source_timer_update(keyboard->key_repeat_source, 0) < 0) {
222 wlr_log(WLR_DEBUG, "failed to disarm key repeat timer");
223 }
224}
225
216static void handle_keyboard_key(struct wl_listener *listener, void *data) { 226static void handle_keyboard_key(struct wl_listener *listener, void *data) {
217 struct sway_keyboard *keyboard = 227 struct sway_keyboard *keyboard =
218 wl_container_of(listener, keyboard, keyboard_key); 228 wl_container_of(listener, keyboard, keyboard_key);
@@ -306,10 +316,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
306 wlr_log(WLR_DEBUG, "failed to set key repeat timer"); 316 wlr_log(WLR_DEBUG, "failed to set key repeat timer");
307 } 317 }
308 } else if (keyboard->repeat_binding) { 318 } else if (keyboard->repeat_binding) {
309 keyboard->repeat_binding = NULL; 319 sway_keyboard_disarm_key_repeat(keyboard);
310 if (wl_event_source_timer_update(keyboard->key_repeat_source, 0) < 0) {
311 wlr_log(WLR_DEBUG, "failed to disarm key repeat timer");
312 }
313 } 320 }
314 321
315 if (binding) { 322 if (binding) {
@@ -517,6 +524,7 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) {
517 } 524 }
518 wl_list_remove(&keyboard->keyboard_key.link); 525 wl_list_remove(&keyboard->keyboard_key.link);
519 wl_list_remove(&keyboard->keyboard_modifiers.link); 526 wl_list_remove(&keyboard->keyboard_modifiers.link);
527 sway_keyboard_disarm_key_repeat(keyboard);
520 wl_event_source_remove(keyboard->key_repeat_source); 528 wl_event_source_remove(keyboard->key_repeat_source);
521 free(keyboard); 529 free(keyboard);
522} 530}