{
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
- if (dispatch->ignore_events)
+ if (dispatch->arbitration.in_arbitration)
return;
switch (event->type) {
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
bool ignore_events = !enable;
- if (ignore_events == dispatch->ignore_events)
+ if (ignore_events == dispatch->arbitration.ignore_events)
return;
- if (ignore_events)
+ if (ignore_events) {
+ libinput_timer_cancel(&dispatch->arbitration.arbitration_timer);
fallback_return_to_neutral_state(dispatch, device);
+ dispatch->arbitration.in_arbitration = true;
+ } else {
+ /* if in-kernel arbitration is in use and there is a touch
+ * and a pen in proximity, lifting the pen out of proximity
+ * causes a touch begin for the touch. On a hand-lift the
+ * proximity out precedes the touch up by a few ms, so we
+ * get what looks like a tap. Fix this by delaying
+ * arbitration by just a little bit so that any touch in
+ * event is caught as palm touch. */
+ libinput_timer_set(&dispatch->arbitration.arbitration_timer,
+ time + ms2us(90));
+ }
- dispatch->ignore_events = ignore_events;
+ dispatch->arbitration.ignore_events = ignore_events;
}
static void
{
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
+ libinput_timer_destroy(&dispatch->arbitration.arbitration_timer);
libinput_timer_destroy(&dispatch->debounce.timer);
libinput_timer_destroy(&dispatch->debounce.timer_short);
libinput_device_init_event_listener(&dispatch->tablet_mode.other.listener);
}
+static void
+fallback_arbitration_timeout(uint64_t now, void *data)
+{
+ struct fallback_dispatch *dispatch = data;
+
+ if (dispatch->arbitration.in_arbitration)
+ dispatch->arbitration.in_arbitration = false;
+}
+
+static void
+fallback_init_arbitration(struct fallback_dispatch *dispatch,
+ struct evdev_device *device)
+{
+ char timer_name[64];
+
+ snprintf(timer_name,
+ sizeof(timer_name),
+ "%s arbitration",
+ evdev_device_get_sysname(device));
+ libinput_timer_init(&dispatch->arbitration.arbitration_timer,
+ evdev_libinput_context(device),
+ timer_name,
+ fallback_arbitration_timeout,
+ dispatch);
+ dispatch->arbitration.in_arbitration = false;
+}
+
struct evdev_dispatch *
fallback_dispatch_create(struct libinput_device *libinput_device)
{
}
fallback_init_debounce(dispatch);
+ fallback_init_arbitration(dispatch, device);
return &dispatch->base;
}
enum evdev_event_type pending_event;
- /* true if we're reading events (i.e. not suspended) but we're
- ignoring them */
- bool ignore_events;
-
struct {
unsigned int button_code;
uint64_t button_time;
*/
struct list paired_keyboard_list;
} lid;
+
+ /* pen/touch arbitration has a delayed state, if ignore_events is
+ * true we want to ignore events, in_arbitration actually filters.
+ */
+ struct {
+ bool ignore_events;
+ bool in_arbitration;
+ struct libinput_timer arbitration_timer;
+ } arbitration;
};
static inline struct fallback_dispatch*
litest_touch_up(finger, 0);
litest_assert_empty_queue(li);
+ litest_timeout_touch_arbitration();
+ libinput_dispatch(li);
+
/* lift finger, expect expect events */
litest_touch_down(finger, 0, 30, 30);
litest_touch_move_to(finger, 0, 30, 30, 80, 80, 10);
}
END_TEST
-START_TEST(intuos_touch_arbitration_late_touch_lift)
+START_TEST(touch_arbitration_late_touch_lift)
{
struct litest_device *tablet = litest_current_device();
+ enum litest_device_type other;
struct litest_device *finger;
struct libinput *li = tablet->libinput;
struct axis_replacement axes[] = {
{ ABS_PRESSURE, 0 },
{ -1, -1 }
};
+ bool is_touchpad;
- finger = litest_add_device(li, LITEST_WACOM_FINGER);
- litest_enable_tap(finger->libinput_device);
+ other = paired_device(tablet);
+ if (other == LITEST_NO_DEVICE)
+ return;
+
+ finger = litest_add_device(li, other);
+ is_touchpad = !libevdev_has_property(finger->evdev, INPUT_PROP_DIRECT);
+ if (is_touchpad)
+ litest_enable_tap(finger->libinput_device);
litest_tablet_proximity_in(tablet, 10, 10, axes);
litest_tablet_motion(tablet, 10, 10, axes);
litest_tablet_motion(tablet, 20, 40, axes);
litest_add("tablet:touch-arbitration", touch_arbitration_remove_touch, LITEST_TABLET, LITEST_ANY);
litest_add("tablet:touch-arbitration", touch_arbitration_remove_tablet, LITEST_TOUCH, LITEST_ANY);
litest_add("tablet:touch-arbitration", touch_arbitration_keep_ignoring, LITEST_TABLET, LITEST_ANY);
-
- litest_add_for_device("tablet:touch-arbitration", intuos_touch_arbitration_late_touch_lift, LITEST_WACOM_INTUOS);
+ litest_add("tablet:touch-arbitration", touch_arbitration_late_touch_lift, LITEST_TABLET, LITEST_ANY);
litest_add_for_device("tablet:quirks", huion_static_btn_tool_pen, LITEST_HUION_TABLET);
litest_add_for_device("tablet:quirks", huion_static_btn_tool_pen_no_timeout_during_usage, LITEST_HUION_TABLET);