diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-01-14 14:06:35 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-14 20:15:23 +0100 |
commit | 2573606b60f0606860634b90749f734cd0e918b7 (patch) | |
tree | 35d9264a20a6e78134c8b39361123143f90b5e32 /sway/input | |
parent | 2257368f1a5617d536c51a3ab242455515313668 (diff) | |
download | sway-2573606b60f0606860634b90749f734cd0e918b7.tar.xz |
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')
-rw-r--r-- | sway/input/keyboard.c | 16 | ||||
-rw-r--r-- | sway/input/seat.c | 1 |
2 files changed, 13 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, keycode, layout_index, 0, keysyms); } +void sway_keyboard_disarm_key_repeat(struct sway_keyboard *keyboard) { + if (!keyboard) { + return; + } + keyboard->repeat_binding = NULL; + if (wl_event_source_timer_update(keyboard->key_repeat_source, 0) < 0) { + wlr_log(WLR_DEBUG, "failed to disarm key repeat timer"); + } +} + static void handle_keyboard_key(struct wl_listener *listener, void *data) { struct sway_keyboard *keyboard = wl_container_of(listener, keyboard, keyboard_key); @@ -306,10 +316,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { wlr_log(WLR_DEBUG, "failed to set key repeat timer"); } } else if (keyboard->repeat_binding) { - keyboard->repeat_binding = NULL; - if (wl_event_source_timer_update(keyboard->key_repeat_source, 0) < 0) { - wlr_log(WLR_DEBUG, "failed to disarm key repeat timer"); - } + sway_keyboard_disarm_key_repeat(keyboard); } if (binding) { @@ -517,6 +524,7 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) { } wl_list_remove(&keyboard->keyboard_key.link); wl_list_remove(&keyboard->keyboard_modifiers.link); + sway_keyboard_disarm_key_repeat(keyboard); wl_event_source_remove(keyboard->key_repeat_source); free(keyboard); } diff --git a/sway/input/seat.c b/sway/input/seat.c index a63999b6..a66a8198 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -542,6 +542,7 @@ void seat_reset_device(struct sway_seat *seat, seat_reset_input_config(seat, seat_device); break; case WLR_INPUT_DEVICE_KEYBOARD: + sway_keyboard_disarm_key_repeat(seat_device->keyboard); sway_keyboard_configure(seat_device->keyboard); break; case WLR_INPUT_DEVICE_TOUCH: |