If the keyboard is removed while dwt thinks it is in active state, that state
is never reset and subsequent touches are ignored.

https://bugs.freedesktop.org/show_bug.cgi?id=101743

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/evdev-mt-touchpad.c |  1 +
 test/test-touchpad.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 0a4f4d98..6ef356b5 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1855,6 +1855,7 @@ tp_interface_device_removed(struct evdev_device *device,
                libinput_device_remove_event_listener(
                                        &tp->dwt.keyboard_listener);
                tp->dwt.keyboard = NULL;
+               tp->dwt.keyboard_active = false;
        }
 
        if (removed_device == tp->lid_switch.lid_switch) {
diff --git a/test/test-touchpad.c b/test/test-touchpad.c
index 33c0d5ba..ffb214ec 100644
--- a/test/test-touchpad.c
+++ b/test/test-touchpad.c
@@ -4127,6 +4127,47 @@ START_TEST(touchpad_dwt_enable_during_tap)
 }
 END_TEST
 
+START_TEST(touchpad_dwt_remove_kbd_while_active)
+{
+       struct litest_device *touchpad = litest_current_device();
+       struct litest_device *keyboard;
+       struct libinput *li = touchpad->libinput;
+
+       if (!has_disable_while_typing(touchpad))
+               return;
+
+       litest_enable_tap(touchpad->libinput_device);
+       enable_dwt(touchpad);
+
+       keyboard = dwt_init_paired_keyboard(li, touchpad);
+       litest_drain_events(li);
+
+       litest_keyboard_key(keyboard, KEY_A, true);
+       litest_keyboard_key(keyboard, KEY_A, false);
+       libinput_dispatch(li);
+
+       litest_touch_down(touchpad, 0, 50, 50);
+       libinput_dispatch(li);
+
+       litest_keyboard_key(keyboard, KEY_A, true);
+       litest_keyboard_key(keyboard, KEY_A, false);
+       litest_drain_events(li);
+
+       litest_delete_device(keyboard);
+       litest_drain_events(li);
+
+       litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 10, 1);
+       litest_touch_up(touchpad, 0);
+       litest_assert_empty_queue(li);
+
+       litest_touch_down(touchpad, 0, 50, 50);
+       litest_touch_move_to(touchpad, 0, 50, 50, 70, 50, 10, 1);
+       litest_touch_up(touchpad, 0);
+       litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+
+}
+END_TEST
+
 START_TEST(touchpad_dwt_apple)
 {
        struct litest_device *touchpad = litest_current_device();
@@ -5359,6 +5400,7 @@ litest_setup_tests_touchpad(void)
        litest_add("touchpad:dwt", touchpad_dwt_enable_during_touch, 
LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_enable_before_touch, 
LITEST_TOUCHPAD, LITEST_ANY);
        litest_add("touchpad:dwt", touchpad_dwt_enable_during_tap, 
LITEST_TOUCHPAD, LITEST_ANY);
+       litest_add("touchpad:dwt", touchpad_dwt_remove_kbd_while_active, 
LITEST_TOUCHPAD, LITEST_ANY);
        litest_add_for_device("touchpad:dwt", touchpad_dwt_apple, 
LITEST_BCM5974);
        litest_add_for_device("touchpad:dwt", touchpad_dwt_acer_hawaii, 
LITEST_ACER_HAWAII_TOUCHPAD);
 
-- 
2.13.0

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to