diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index c97452a8..9ba7604d 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1999,9 +1999,15 @@ static void tp_interface_remove(struct evdev_dispatch *dispatch) { struct tp_dispatch *tp = tp_dispatch(dispatch); + struct evdev_paired_keyboard *kbd; libinput_timer_cancel(&tp->arbitration.arbitration_timer); + list_for_each_safe(kbd, &tp->dwt.paired_keyboard_list, link) { + evdev_paired_keyboard_destroy(kbd); + } + tp->dwt.keyboard_active = false; + tp_remove_tap(tp); tp_remove_buttons(tp); tp_remove_sendevents(tp); diff --git a/test/test-touchpad.c b/test/test-touchpad.c index b7b34598..4bd14752 100644 --- a/test/test-touchpad.c +++ b/test/test-touchpad.c @@ -5119,6 +5119,23 @@ START_TEST(touchpad_dwt_multiple_keyboards) } END_TEST +START_TEST(touchpad_dwt_remove_before_keyboard) +{ + struct litest_device *keyboard = litest_current_device(); + struct litest_device *touchpad; + struct libinput *li = keyboard->libinput; + + touchpad = litest_add_device(li, LITEST_SYNAPTICS_RMI4); + ck_assert(has_disable_while_typing(touchpad)); + + libinput_dispatch(li); + + /* remove the touchpad before the keyboard. + * this test can fail in valgrind only */ + litest_delete_device(touchpad); +} +END_TEST + START_TEST(touchpad_dwt_multiple_keyboards_bothkeys) { struct litest_device *touchpad = litest_current_device(); @@ -7293,6 +7310,7 @@ TEST_COLLECTION(touchpad) litest_add_for_device(touchpad_dwt_multiple_keyboards_bothkeys, LITEST_SYNAPTICS_I2C); litest_add_for_device(touchpad_dwt_multiple_keyboards_bothkeys_modifier, LITEST_SYNAPTICS_I2C); litest_add_ranged_for_device(touchpad_dwt_multiple_keyboards_remove, LITEST_SYNAPTICS_I2C, &twice); + litest_add_for_device(touchpad_dwt_remove_before_keyboard, LITEST_KEYBOARD); litest_add(touchpad_thumb_lower_area_movement, LITEST_CLICKPAD, LITEST_ANY); litest_add(touchpad_thumb_lower_area_movement_rethumb, LITEST_CLICKPAD, LITEST_ANY);