Drop vector_length(), replace with hypot(3)
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 20 Jul 2015 01:09:19 +0000 (11:09 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 20 Jul 2015 01:18:53 +0000 (11:18 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad.c
src/libinput-util.h
test/pointer.c

index b06449b..b73138c 100644 (file)
@@ -439,7 +439,7 @@ tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t)
        ydist *= tp->buttons.motion_dist.y_scale_coeff;
 
        /* 3mm movement -> unpin */
-       if (vector_length(xdist, ydist) >= 3.0) {
+       if (hypot(xdist, ydist) >= 3.0) {
                t->pinned.is_pinned = false;
                return;
        }
index f27bcfd..b18aece 100644 (file)
@@ -299,10 +299,4 @@ int parse_mouse_wheel_click_angle_property(const char *prop);
 double parse_trackpoint_accel_property(const char *prop);
 bool parse_dimension_property(const char *prop, size_t *width, size_t *height);
 
-static inline double
-vector_length(double x, double y)
-{
-       return sqrt(x * x + y * y);
-}
-
 #endif /* LIBINPUT_UTIL_H */
index 28d7c9a..c781505 100644 (file)
@@ -197,7 +197,7 @@ START_TEST(pointer_motion_relative_min_decel)
        ck_assert((evx == 0.0) == (dx == 0));
        ck_assert((evy == 0.0) == (dy == 0));
 
-       len = vector_length(evx, evy);
+       len = hypot(evx, evy);
        ck_assert(fabs(len) >= 0.3);
 
        libinput_event_destroy(event);