Add a normalized_is_zero helper function, and use it where applicable.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
tp_filter_motion(tp, &delta.x, &delta.y, &unaccel.x, &unaccel.y, time);
- if (delta.x != 0.0 || delta.y != 0.0 ||
- unaccel.x != 0.0 || unaccel.y != 0.0) {
+ if (!normalized_is_zero(delta) || !normalized_is_zero(unaccel)) {
pointer_notify_motion(&tp->device->base, time,
&delta, &unaccel);
}
delta = tp_get_average_touches_delta(tp);
tp_filter_motion(tp, &delta.x, &delta.y, NULL, NULL, time);
- if (delta.x == 0.0 && delta.y == 0.0)
+ if (normalized_is_zero(delta))
return;
tp_gesture_start(tp, time);
unaccelerated.x = *dx;
unaccelerated.y = *dy;
- if (unaccelerated.x != 0.0 || unaccelerated.y != 0.0)
+ if (!normalized_is_zero(unaccelerated))
accelerated = filter_dispatch(tp->device->pointer.filter,
&unaccelerated,
tp,
/* Apply pointer acceleration. */
accel = filter_dispatch(device->pointer.filter, &unaccel, device, time);
- if (accel.x == 0.0 && accel.y == 0.0 &&
- unaccel.x == 0.0 && unaccel.y == 0.0) {
+ if (normalized_is_zero(accel) && normalized_is_zero(unaccel))
break;
- }
pointer_notify_motion(base, time, &accel, &unaccel);
break;
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
event.x = 0.0;
- if (event.x != 0.0 || event.y != 0.0) {
+ if (!normalized_is_zero(event)) {
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
evdev_notify_axis(device,
time,
return hypot(norm.x, norm.y);
}
+static inline int
+normalized_is_zero(struct normalized_coords norm)
+{
+ return norm.x == 0.0 && norm.y == 0.0;
+}
+
#endif /* LIBINPUT_PRIVATE_H */