The scroll and zoom gestures use of how far the fingers have travelled
as a way to determine how many times to send the scroll/zoom event.
When a gesture first starts, however, the fingers have already moved a
large distance simply to have the gesture be recognized. This may cause
a rapid and undesired "catch up" effect due to the large built-up delta.

To work around this, when a gesture starts, we reset the wcmGestureState
so that the functions are working with a clean slate and do not see the
large delta.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/wcmTouchFilter.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
index 3062cde..e945a9d 100644
--- a/src/wcmTouchFilter.c
+++ b/src/wcmTouchFilter.c
@@ -616,6 +616,7 @@ static void wcmFingerScroll(WacomDevicePtr priv)
        int i = 0, dist = 0;
        WacomFilterState filterd;  /* borrow this struct */
        int max_spread = common->wcmGestureParameters.wcmMaxScrollFingerSpread;
+       int gestureStart = 0;
 
        if (!common->wcmGesture)
                return;
@@ -640,6 +641,7 @@ static void wcmFingerScroll(WacomDevicePtr priv)
                                /* left button might be down. Send it up first 
*/
                                wcmSendButtonClick(priv, 1, 0);
                                common->wcmGestureMode = GESTURE_SCROLL_MODE;
+                               gestureStart = 1;
                        }
                }
        }
@@ -648,6 +650,13 @@ static void wcmFingerScroll(WacomDevicePtr priv)
        if (common->wcmGestureMode != GESTURE_SCROLL_MODE)
                return;
 
+       /* forget history leading up to the beginning of the gesture */
+       if (gestureStart)
+       {
+               common->wcmGestureState[0] = ds[0];
+               common->wcmGestureState[1] = ds[1];
+       }
+
        /* initialize the points so we can rotate them */
        filterd.x[0] = ds[0].x;
        filterd.y[0] = ds[0].y;
@@ -713,9 +722,9 @@ static void wcmFingerZoom(WacomDevicePtr priv)
        WacomCommonPtr common = priv->common;
        WacomDeviceState ds[2] = {};
        int count, button;
-       int dist = touchDistance(common->wcmGestureState[0],
-                       common->wcmGestureState[1]);
+       int dist;
        int max_spread = common->wcmGestureParameters.wcmMaxScrollFingerSpread;
+       int gestureStart = 0;
 
        if (!common->wcmGesture)
                return;
@@ -738,13 +747,21 @@ static void wcmFingerZoom(WacomDevicePtr priv)
                        /* fingers moved apart more than 3 times
                         * wcmMaxScrollFingerSpread, zoom mode is entered */
                        common->wcmGestureMode = GESTURE_ZOOM_MODE;
+                       gestureStart = 1;
                }
        }
 
        if (common->wcmGestureMode != GESTURE_ZOOM_MODE)
                return;
 
-       dist = touchDistance(ds[0], ds[1]) - dist;
+       /* forget history leading up to the beginning of the gesture */
+       if (gestureStart)
+       {
+               common->wcmGestureState[0] = ds[0];
+               common->wcmGestureState[1] = ds[1];
+       }
+
+       dist = touchDistance(ds[0], ds[1]) - 
touchDistance(common->wcmGestureState[0], common->wcmGestureState[1]);
        count = (int)((1.0 * 
abs(dist)/common->wcmGestureParameters.wcmZoomDistance) + 0.5);
 
        /* user might have changed from left to right or vice versa */
-- 
2.1.0


------------------------------------------------------------------------------
Slashdot TV.  Video for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to