diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 09713922..4ba4ad28 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -530,15 +530,11 @@ static bool tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, struct tp_touch *t) { - int threshold = DEFAULT_TAP_MOVE_THRESHOLD; - struct normalized_coords normalized; + struct normalized_coords norm = + tp_normalize_delta(tp, device_delta(t->point, + t->tap.initial)); - normalized = tp_normalize_delta(tp, - device_delta(t->point, - t->tap.initial)); - - return normalized.x * normalized.x + normalized.y * normalized.y - > threshold * threshold; + return normalized_length(norm) > DEFAULT_TAP_MOVE_THRESHOLD; } static bool diff --git a/src/filter.c b/src/filter.c index dc299286..dd4bd58d 100644 --- a/src/filter.c +++ b/src/filter.c @@ -137,11 +137,9 @@ tracker_by_offset(struct pointer_accelerator *accel, unsigned int offset) static double calculate_tracker_velocity(struct pointer_tracker *tracker, uint64_t time) { - double distance; double tdelta = time - tracker->time + 1; - distance = hypot(tracker->delta.x, tracker->delta.y); - return distance / tdelta; /* units/ms */ + return normalized_length(tracker->delta) / tdelta; /* units/ms */ } static double diff --git a/src/libinput-private.h b/src/libinput-private.h index 73f8d157..31f2dbc1 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -24,6 +24,7 @@ #define LIBINPUT_PRIVATE_H #include +#include #include "linux/input.h" @@ -373,4 +374,10 @@ device_delta(struct device_coords a, struct device_coords b) return delta; } +static inline double +normalized_length(struct normalized_coords norm) +{ + return hypot(norm.x, norm.y); +} + #endif /* LIBINPUT_PRIVATE_H */