tablet: don't disable the proximity quirk on good sequences
authorPeter Hutterer <peter.hutterer@who-t.net>
Sun, 26 May 2019 23:13:06 +0000 (09:13 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 27 May 2019 00:16:35 +0000 (10:16 +1000)
There are tablets out there that *sometimes* send the right event sequence,
but are generally broken. So let's not disable that quirk even if we do get a
right sequence.

Affected devices: Lenovo Flex 5
Fixes #248
Fixes #290

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

index 1f17df1f3841b01e902b93ebad0a6bda7dd1d362..8439cffed7c48a52a78ff07e62a285bc4146750b 100644 (file)
@@ -1718,10 +1718,11 @@ tablet_update_tool_state(struct tablet_dispatch *tablet,
                         * events it means the tablet will give us the right
                         * events after all and we can disable our
                         * timer-based proximity out.
+                        *
+                        * We can't do so permanently though, some tablets
+                        * send the correct event sequence occasionally but
+                        * are broken otherwise.
                         */
-                       if (!tablet->quirks.proximity_out_in_progress)
-                               tablet->quirks.need_to_force_prox_out = false;
-
                        libinput_timer_cancel(&tablet->quirks.prox_out_timer);
                }
        }
@@ -1873,14 +1874,12 @@ tablet_proximity_out_quirk_timer_func(uint64_t now, void *data)
 
        evdev_log_debug(tablet->device, "tablet: forcing proximity after timeout\n");
 
-       tablet->quirks.proximity_out_in_progress = true;
        ARRAY_FOR_EACH(events, e) {
                tablet->base.interface->process(&tablet->base,
                                                 tablet->device,
                                                 e,
                                                 now);
        }
-       tablet->quirks.proximity_out_in_progress = false;
 
        tablet->quirks.proximity_out_forced = true;
 }
@@ -2018,8 +2017,7 @@ tablet_check_initial_proximity(struct evdev_device *device,
                return;
 
        tablet_update_tool(tablet, device, tool, state);
-       if (tablet->quirks.need_to_force_prox_out)
-               tablet_proximity_out_quirk_set_timer(tablet, libinput_now(li));
+       tablet_proximity_out_quirk_set_timer(tablet, libinput_now(li));
 
        tablet->current_tool.id =
                libevdev_get_event_value(device->evdev,
@@ -2212,10 +2210,6 @@ tablet_init(struct tablet_dispatch *tablet,
 
        tablet_set_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
 
-       /* We always enable the proximity out quirk, but disable it once a
-          device gives us the right event sequence */
-       tablet->quirks.need_to_force_prox_out = true;
-
        libinput_timer_init(&tablet->quirks.prox_out_timer,
                            tablet_libinput_context(tablet),
                            "proxout",
index 5af0cfbb4650b0877a70efcb6086a334560fe99f..de930aaac2051f629776dfca4fb9b7f2637eb115 100644 (file)
@@ -92,13 +92,9 @@ struct tablet_dispatch {
        enum evdev_arbitration_state arbitration;
 
        struct {
-               bool need_to_force_prox_out;
                struct libinput_timer prox_out_timer;
                bool proximity_out_forced;
                uint64_t last_event_time;
-
-               /* true while injecting BTN_TOOL_PEN events */
-               bool proximity_out_in_progress;
        } quirks;
 };
 
index b8fa717a355ddb24f350a73343a3387b922c5722..722c6478c6604a23a036be8840641653654490bc 100644 (file)
@@ -4514,10 +4514,6 @@ START_TEST(touch_arbitration_outside_rect)
        x = 20;
        y = 45;
 
-       /* disable prox-out timer quirk */
-       litest_tablet_proximity_in(dev, x, y - 1, axes);
-       litest_tablet_proximity_out(dev);
-
        litest_tablet_proximity_in(dev, x, y - 1, axes);
        litest_drain_events(li);
 
@@ -4531,16 +4527,25 @@ START_TEST(touch_arbitration_outside_rect)
        litest_touch_sequence(finger, 0, x - 10, y + 2, x - 10, y + 20, 3);
        libinput_dispatch(li);
        litest_assert_touch_sequence(li);
+       /* tablet event so we don't time out for proximity */
+       litest_tablet_motion(dev, x, y - 0.1, axes);
+       litest_drain_events(li);
 
        /* above rect */
        litest_touch_sequence(finger, 0, x + 2, y - 35, x + 20, y - 10, 3);
        libinput_dispatch(li);
        litest_assert_touch_sequence(li);
+       /* tablet event so we don't time out for proximity */
+       litest_tablet_motion(dev, x, y + 0.1, axes);
+       litest_drain_events(li);
 
        /* right of rect */
        litest_touch_sequence(finger, 0, x + 80, y + 2, x + 20, y + 10, 3);
        libinput_dispatch(li);
        litest_assert_touch_sequence(li);
+       /* tablet event so we don't time out for proximity */
+       litest_tablet_motion(dev, x, y - 0.1, axes);
+       litest_drain_events(li);
 
 #if 0
        /* This *should* work but the Cintiq test devices is <200mm
@@ -4623,11 +4628,6 @@ START_TEST(touch_arbitration_stop_touch)
 
        is_touchpad = !libevdev_has_property(finger->evdev, INPUT_PROP_DIRECT);
 
-       /* disable prox-out timer quirk */
-       litest_tablet_proximity_in(dev, 30, 30, axes);
-       litest_tablet_proximity_out(dev);
-       litest_drain_events(li);
-
        litest_touch_down(finger, 0, 30, 30);
        litest_touch_move_to(finger, 0, 30, 30, 80, 80, 10);