switch(tp->tap.state) {
case TAP_STATE_IDLE:
- if (!tp->tap.enabled)
- break;
-
tp_tap_idle_handle_event(tp, t, event, time);
break;
case TAP_STATE_TOUCH:
return dx * dx + dy * dy > threshold * threshold;
}
+static bool
+tp_tap_enabled(struct tp_dispatch *tp)
+{
+ return tp->tap.enabled && !tp->tap.suspended;
+}
+
int
tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
{
struct tp_touch *t;
int filter_motion = 0;
- if (tp->tap.suspended)
+ if (!tp_tap_enabled(tp))
return 0;
/* Handle queued button pressed events from clickpads. For touchpads
}
}
+static void
+tp_tap_enabled_update(struct tp_dispatch *tp, bool suspended, bool enabled, uint64_t time)
+{
+ bool was_enabled = tp_tap_enabled(tp);
+
+ tp->tap.suspended = suspended;
+ tp->tap.enabled = enabled;
+
+ if (tp_tap_enabled(tp) == was_enabled)
+ return;
+
+ if (tp_tap_enabled(tp)) {
+ /* Must restart in DEAD if fingers are down atm */
+ tp->tap.state =
+ tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE;
+ } else {
+ tp_release_all_taps(tp, time);
+ }
+}
+
static int
tp_tap_config_count(struct libinput_device *device)
{
tp_tap_config_set_enabled(struct libinput_device *device,
enum libinput_config_tap_state enabled)
{
- struct evdev_dispatch *dispatch;
- struct tp_dispatch *tp = NULL;
+ struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch;
+ struct tp_dispatch *tp = container_of(dispatch, tp, base);
- dispatch = ((struct evdev_device *) device)->dispatch;
- tp = container_of(dispatch, tp, base);
-
- tp->tap.enabled = (enabled == LIBINPUT_CONFIG_TAP_ENABLED);
+ tp_tap_enabled_update(tp, tp->tap.suspended,
+ (enabled == LIBINPUT_CONFIG_TAP_ENABLED),
+ libinput_now(device->seat->libinput));
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
void
tp_tap_suspend(struct tp_dispatch *tp, uint64_t time)
{
- tp->tap.suspended = true;
- tp_release_all_taps(tp, time);
+ tp_tap_enabled_update(tp, true, tp->tap.enabled, time);
}
void
tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
{
- tp->tap.suspended = false;
- /* Must restart in DEAD if fingers are down atm */
- tp->tap.state = tp->nfingers_down ? TAP_STATE_DEAD : TAP_STATE_IDLE;
+ tp_tap_enabled_update(tp, false, tp->tap.enabled, time);
}