[PATCH libinput v3] touchpad: Fix log_bug_libinput calls on tap enable with fingers down
Hans de Goede
hdegoede at redhat.com
Wed Nov 5 01:48:59 PST 2014
Before this commit the tap code deals with enabled being set to false,
by waiting for tap.state to become IDLE, and then ignoring any events from
that point on.
This causes a problem when enabled gets set to true again while fingers are
down, because when in IDLE no release events are expected, so once a release
event for one of the fingers is send, log_bug_libinput gets called.
This commit fixes this by making enabled use the same mechanism for enabled
state transitions as the tap suspend / resume code.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
--
Changes in v2:
-New addition of this patch to patch-set
Changes in v3:
-Make tp_tap_enabled_update take the new enabled and suspended value, rather
then having the caller update them and pass in an old_enabled value.
---
src/evdev-mt-touchpad-tap.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 61c0139..5b197b8 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -476,9 +476,6 @@ tp_tap_handle_event(struct tp_dispatch *tp,
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:
@@ -540,13 +537,19 @@ tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, struct tp_touch *t)
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
@@ -623,6 +626,26 @@ tp_tap_handle_timeout(uint64_t time, void *data)
}
}
+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)
{
@@ -639,13 +662,12 @@ static enum libinput_config_status
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;
}
@@ -718,14 +740,11 @@ tp_release_all_taps(struct tp_dispatch *tp, uint64_t now)
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);
}
--
2.1.0
More information about the wayland-devel
mailing list