Fix scroll-threshold check for edge-scrolling to use normalized coordinates
authorHans de Goede <hdegoede@redhat.com>
Tue, 24 Mar 2015 12:14:17 +0000 (13:14 +0100)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 24 Mar 2015 23:18:51 +0000 (09:18 +1000)
The DEFAULT_SCROLL_THRESHOLD value is a TP_MM_TO_DPI_NORMALIZED value and as
such should be compared to a normalized value. But since commit 8101e43774
("touchpad: switch delta handling to typesafe coordinates"), the
initial_dx / initial_dy values initial_delta points to are no longer in
normalized coordinates, as the result of tp_normalize_delta is now stored
into the normalized value.

This commit changes the check to use the delta pointer which does point to
the normalized x/y values. While at it also use the zero variable to
set normalized to zero rather then manually setting x and y to 0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad-edge-scroll.c

index 26d6bbc..d304316 100644 (file)
@@ -313,7 +313,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
        struct tp_touch *t;
        enum libinput_pointer_axis axis;
        double *delta;
-       double initial_dx, initial_dy, *initial_delta;
+       double initial_dx, initial_dy;
        struct normalized_coords normalized;
        const struct normalized_coords zero = { 0.0, 0.0 };
        const struct discrete_coords zero_discrete = { 0.0, 0.0 };
@@ -340,12 +340,10 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
                        case EDGE_RIGHT:
                                axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
                                delta = &normalized.y;
-                               initial_delta = &initial_dy;
                                break;
                        case EDGE_BOTTOM:
                                axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
                                delta = &normalized.x;
-                               initial_delta = &initial_dx;
                                break;
                        default: /* EDGE_RIGHT | EDGE_BOTTOM */
                                continue; /* Don't know direction yet, skip */
@@ -369,10 +367,8 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
                                           initial_dx,
                                           initial_dy,
                                           &normalized);
-                       if (fabs(*initial_delta) < DEFAULT_SCROLL_THRESHOLD) {
-                               normalized.x = 0.0;
-                               normalized.y = 0.0;
-                       }
+                       if (fabs(*delta) < DEFAULT_SCROLL_THRESHOLD)
+                               normalized = zero;
                        break;
                case EDGE_SCROLL_TOUCH_STATE_EDGE:
                        break;