mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 14:40:26 +01:00
Add a normalized_is_zero helper function
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>
This commit is contained in:
parent
674490ca60
commit
b87251ca71
4 changed files with 11 additions and 8 deletions
|
|
@ -99,8 +99,7 @@ tp_gesture_post_pointer_motion(struct tp_dispatch *tp, uint64_t time)
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
@ -114,7 +113,7 @@ tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ tp_filter_motion(struct tp_dispatch *tp,
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -268,10 +268,8 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
|
|||
/* 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;
|
||||
|
|
@ -2098,7 +2096,7 @@ evdev_post_scroll(struct evdev_device *device,
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -380,4 +380,10 @@ normalized_length(struct normalized_coords norm)
|
|||
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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue