fallback: when force-releasing keys, release them directly
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 30 Jan 2019 04:10:28 +0000 (14:10 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 31 Jan 2019 05:09:44 +0000 (15:09 +1000)
An emulated button is recorded as BTN_MIDDLE in the key down mask. If the
device is removed in that state, the BTN_MIDDLE event processed triggers
an assertion when we try to send out the event twice.

Fixes #201

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-fallback.c
test/test-pointer.c

index 8d319d188a15dcb6f201c42ebeb1af3bc68d3e6a..c064557a2ca7e5ba5c1440751278b3a424ba2f6b 100644 (file)
@@ -1095,7 +1095,7 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
                                LIBINPUT_KEY_STATE_RELEASED);
                        break;
                case KEY_TYPE_BUTTON:
-                       evdev_pointer_notify_physical_button(
+                       evdev_pointer_notify_button(
                                device,
                                time,
                                evdev_to_left_handed(device, code),
index 59af12d52d5cfce61342e4a7f0c1d1659a25c9cc..7af2261aa291961cea1cbac1eff5ef855748badb 100644 (file)
@@ -2107,6 +2107,37 @@ START_TEST(middlebutton_button_scrolling_middle)
 }
 END_TEST
 
+START_TEST(middlebutton_device_remove_while_down)
+{
+       struct litest_device *dev = litest_current_device();
+       struct libinput_device *device = dev->libinput_device;
+       struct libinput *li = dev->libinput;
+       enum libinput_config_status status;
+
+       libinput_device_config_scroll_set_method(device,
+                                                LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
+       status = libinput_device_config_middle_emulation_set_enabled(
+                               device,
+                               LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
+       if (status == LIBINPUT_CONFIG_STATUS_UNSUPPORTED)
+               return;
+
+       litest_drain_events(li);
+
+       litest_event(dev, EV_KEY, BTN_LEFT, 1);
+       litest_event(dev, EV_SYN, SYN_REPORT, 0);
+       litest_event(dev, EV_KEY, BTN_RIGHT, 1);
+       litest_event(dev, EV_SYN, SYN_REPORT, 0);
+       libinput_dispatch(li);
+
+       litest_assert_button_event(li,
+                                  BTN_MIDDLE,
+                                  LIBINPUT_BUTTON_STATE_PRESSED);
+
+       litest_assert_empty_queue(li);
+}
+END_TEST
+
 START_TEST(pointer_time_usec)
 {
        struct litest_device *dev = litest_current_device();
@@ -2673,6 +2704,7 @@ TEST_COLLECTION(pointer)
        litest_add_for_device("pointer:middlebutton", middlebutton_default_alps, LITEST_ALPS_SEMI_MT);
        litest_add("pointer:middlebutton", middlebutton_button_scrolling, LITEST_RELATIVE|LITEST_BUTTON, LITEST_CLICKPAD);
        litest_add("pointer:middlebutton", middlebutton_button_scrolling_middle, LITEST_RELATIVE|LITEST_BUTTON, LITEST_CLICKPAD);
+       litest_add("pointer:middlebutton", middlebutton_device_remove_while_down, LITEST_BUTTON, LITEST_CLICKPAD);
 
        litest_add_ranged("pointer:state", pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, &axis_range);