From cad73f402328897f21e6ae0cdc0e6d2500c1395d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 6 Nov 2017 14:22:06 +1000 Subject: [PATCH] touchpad: move the tap state bug messages to a helper function There's no need for a custom error message everywhere, it's better to log the current state and the event. Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-tap.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index f01487fe..bfcef973 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -96,6 +96,16 @@ tap_event_to_str(enum tap_event event) return NULL; } +static inline void +log_tap_bug(struct tp_dispatch *tp, enum tap_event event) +{ + evdev_log_bug_libinput(tp->device, + "invalid tap event %s in state %s\n", + tap_event_to_str(event), + tap_state_to_str(tp->tap.state)); + +} + static void tp_tap_notify(struct tp_dispatch *tp, uint64_t time, @@ -158,8 +168,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, case TAP_EVENT_RELEASE: break; case TAP_EVENT_MOTION: - evdev_log_bug_libinput(tp->device, - "invalid tap event, no fingers are down\n"); + log_tap_bug(tp, event); break; case TAP_EVENT_TIMEOUT: break; @@ -167,8 +176,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, tp->tap.state = TAP_STATE_DEAD; break; case TAP_EVENT_THUMB: - evdev_log_bug_libinput(tp->device, - "invalid tap event, no fingers down, no thumb\n"); + log_tap_bug(tp, event); break; } } @@ -256,8 +264,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_MOTION: case TAP_EVENT_RELEASE: - evdev_log_bug_libinput(tp->device, - "invalid tap event when fingers are up\n"); + log_tap_bug(tp, event); break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_DRAGGING_OR_DOUBLETAP; @@ -592,8 +599,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, { switch (event) { case TAP_EVENT_RELEASE: - evdev_log_bug_libinput(tp->device, - "invalid tap event, no fingers are down\n"); + log_tap_bug(tp, event); break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_MULTITAP_DOWN; @@ -605,8 +611,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, tp_tap_set_timer(tp, time); break; case TAP_EVENT_MOTION: - evdev_log_bug_libinput(tp->device, - "invalid tap event, no fingers are down\n"); + log_tap_bug(tp, event); break; case TAP_EVENT_TIMEOUT: tp->tap.state = TAP_STATE_IDLE;