aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-11-27 20:57:44 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-28 10:34:49 +0100
commit0cdad33f1a08f86675efd56c2236f903af744162 (patch)
treea058cd922a8d6d691064b94f217cbb1f8c20c2c7
parentconfig: improvements to the reload validation (diff)
downloadsway-0cdad33f1a08f86675efd56c2236f903af744162.tar.gz
sway-0cdad33f1a08f86675efd56c2236f903af744162.tar.zst
sway-0cdad33f1a08f86675efd56c2236f903af744162.zip
input/keyboard: reset seat keyboard on destroy
If a sway keyboard is being destroyed, then the keyboard is being removed from a seat. If the associated wlr_keyboard is the currently set keyboard for the wlr_seat, then we need to reset the wlr_seat's keyboard to NULL so it doesn't reference an invalid device for the seat. The next configured keyboard from the seat or the next keyboard from that seat that has an event will then become the seat keyboard. Similarly, this needs to be done for a wlr_keyboard_group's keyboard when the wlr_keyboard_group is being destroyed.
-rw-r--r--sway/input/keyboard.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index a42ce911..c4ce8246 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -675,9 +675,7 @@ static void sway_keyboard_group_remove(struct sway_keyboard *keyboard) {
675 struct sway_keyboard_group *sway_group = wlr_group->data; 675 struct sway_keyboard_group *sway_group = wlr_group->data;
676 wlr_group->data = NULL; 676 wlr_group->data = NULL;
677 wl_list_remove(&sway_group->link); 677 wl_list_remove(&sway_group->link);
678 wl_list_remove(&sway_group->keyboard_key.link); 678 sway_keyboard_destroy(sway_group->seat_device->keyboard);
679 wl_list_remove(&sway_group->keyboard_modifiers.link);
680 free(sway_group->seat_device->keyboard);
681 free(sway_group->seat_device->input_device); 679 free(sway_group->seat_device->input_device);
682 free(sway_group->seat_device); 680 free(sway_group->seat_device);
683 free(sway_group); 681 free(sway_group);
@@ -921,6 +919,11 @@ void sway_keyboard_destroy(struct sway_keyboard *keyboard) {
921 if (keyboard->seat_device->input_device->wlr_device->keyboard->group) { 919 if (keyboard->seat_device->input_device->wlr_device->keyboard->group) {
922 sway_keyboard_group_remove(keyboard); 920 sway_keyboard_group_remove(keyboard);
923 } 921 }
922 struct wlr_seat *wlr_seat = keyboard->seat_device->sway_seat->wlr_seat;
923 struct sway_input_device *device = keyboard->seat_device->input_device;
924 if (wlr_seat_get_keyboard(wlr_seat) == device->wlr_device->keyboard) {
925 wlr_seat_set_keyboard(wlr_seat, NULL);
926 }
924 if (keyboard->keymap) { 927 if (keyboard->keymap) {
925 xkb_keymap_unref(keyboard->keymap); 928 xkb_keymap_unref(keyboard->keymap);
926 } 929 }