Delta movements on most slower movements are less than 1.0 per event, so we'd end up with an undefined direction for all of them. This led to the velocity being calculated across opposite movements rather than (as intended) across movements within a shared octant.
Signed-off-by: Peter Hutterer <[email protected]> --- src/libinput-util.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libinput-util.h b/src/libinput-util.h index bd71a1f..9191823 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -111,28 +111,28 @@ enum directions { }; static inline int -vector_get_direction(int dx, int dy) +vector_get_direction(double dx, double dy) { int dir = UNDEFINED_DIRECTION; int d1, d2; double r; - if (abs(dx) < 2 && abs(dy) < 2) { - if (dx > 0 && dy > 0) + if (fabs(dx) < 2.0 && fabs(dy) < 2.0) { + if (dx > 0.0 && dy > 0.0) dir = S | SE | E; - else if (dx > 0 && dy < 0) + else if (dx > 0.0 && dy < 0.0) dir = N | NE | E; - else if (dx < 0 && dy > 0) + else if (dx < 0.0 && dy > 0.0) dir = S | SW | W; - else if (dx < 0 && dy < 0) + else if (dx < 0.0 && dy < 0.0) dir = N | NW | W; - else if (dx > 0) + else if (dx > 0.0) dir = NE | E | SE; - else if (dx < 0) + else if (dx < 0.0) dir = NW | W | SW; - else if (dy > 0) + else if (dy > 0.0) dir = SE | S | SW; - else if (dy < 0) + else if (dy < 0.0) dir = NE | N | NW; } else { /* Calculate r within the interval [0 to 8) -- 2.3.2 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
