static void
fallback_interface_toggle_touch(struct evdev_dispatch *evdev_dispatch,
struct evdev_device *device,
- bool enable,
+ enum evdev_arbitration_state which,
uint64_t time)
{
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
- bool ignore_events = !enable;
- if (ignore_events == dispatch->arbitration.ignore_events)
+ if (which == dispatch->arbitration.state)
return;
- if (ignore_events) {
- libinput_timer_cancel(&dispatch->arbitration.arbitration_timer);
- fallback_return_to_neutral_state(dispatch, device);
- dispatch->arbitration.in_arbitration = true;
- } else {
+ switch (which) {
+ case ARBITRATION_NOT_ACTIVE:
/* 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
* event is caught as palm touch. */
libinput_timer_set(&dispatch->arbitration.arbitration_timer,
time + ms2us(90));
+ break;
+ case ARBITRATION_IGNORE_ALL:
+ libinput_timer_cancel(&dispatch->arbitration.arbitration_timer);
+ fallback_return_to_neutral_state(dispatch, device);
+ dispatch->arbitration.in_arbitration = true;
+ break;
}
- dispatch->arbitration.ignore_events = ignore_events;
+ dispatch->arbitration.state = which;
}
static void
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.
+ /* pen/touch arbitration has a delayed state,
+ * in_arbitration is what decides when to filter.
*/
struct {
- bool ignore_events;
+ enum evdev_arbitration_state state;
bool in_arbitration;
struct libinput_timer arbitration_timer;
} arbitration;
struct tp_touch *t,
uint64_t time)
{
- if (!tp->arbitration.in_arbitration)
+ if (tp->arbitration.state == ARBITRATION_NOT_ACTIVE)
return false;
t->palm.state = PALM_ARBITRATION;
{
struct tp_dispatch *tp = data;
- if (tp->arbitration.in_arbitration)
- tp->arbitration.in_arbitration = false;
+ if (tp->arbitration.state != ARBITRATION_NOT_ACTIVE)
+ tp->arbitration.state = ARBITRATION_NOT_ACTIVE;
}
static void
tp_interface_toggle_touch(struct evdev_dispatch *dispatch,
struct evdev_device *device,
- bool enable,
+ enum evdev_arbitration_state which,
uint64_t time)
{
struct tp_dispatch *tp = tp_dispatch(dispatch);
- bool arbitrate = !enable;
- if (arbitrate == tp->arbitration.in_arbitration)
+ if (which == tp->arbitration.state)
return;
- if (arbitrate) {
+ switch (which) {
+ case ARBITRATION_IGNORE_ALL:
libinput_timer_cancel(&tp->arbitration.arbitration_timer);
tp_clear_state(tp);
- tp->arbitration.in_arbitration = true;
- } else {
+ tp->arbitration.state = which;
+ break;
+ case ARBITRATION_NOT_ACTIVE:
/* 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
* event is caught as palm touch. */
libinput_timer_set(&tp->arbitration.arbitration_timer,
time + ms2us(90));
+ break;
}
}
tp_libinput_context(tp),
timer_name,
tp_arbitration_timeout, tp);
- tp->arbitration.in_arbitration = false;
+ tp->arbitration.state = ARBITRATION_NOT_ACTIVE;
}
static void
/* pen/touch arbitration */
struct {
- bool in_arbitration;
+ enum evdev_arbitration_state state;
struct libinput_timer arbitration_timer;
} arbitration;
uint64_t time)
{
struct evdev_dispatch *dispatch;
+ enum evdev_arbitration_state which;
if (touch_device == NULL)
return;
+ if (enable)
+ which = ARBITRATION_NOT_ACTIVE;
+ else
+ which = ARBITRATION_IGNORE_ALL;
+
dispatch = touch_device->dispatch;
if (dispatch->interface->toggle_touch)
dispatch->interface->toggle_touch(dispatch,
touch_device,
- enable,
+ which,
time);
}
DEBOUNCE_ACTIVE,
};
+enum evdev_arbitration_state {
+ ARBITRATION_NOT_ACTIVE,
+ ARBITRATION_IGNORE_ALL,
+};
+
struct evdev_device {
struct libinput_device base;
* enable/disable touch capabilities */
void (*toggle_touch)(struct evdev_dispatch *dispatch,
struct evdev_device *device,
- bool enable,
+ enum evdev_arbitration_state which,
uint64_t now);
/* Return the state of the given switch */