QQuickWindow touch event compression: retain previous positions
authorShawn Rutledge <shawn.rutledge@digia.com>
Fri, 13 Mar 2015 14:13:22 +0000 (15:13 +0100)
committerShawn Rutledge <shawn.rutledge@digia.com>
Fri, 20 Mar 2015 15:14:41 +0000 (15:14 +0000)
The previous positions in the delayed touch event should be from
the first touchpoint which is being delayed, not updated based on
subsequent updates that are being merged into it.  Clarified
naming and comments in this section.

Task-number: QTBUG-40167
Change-Id: Ie419267e4a33277f9154bd80f5bce104e52d773e
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/quick/items/qquickwindow.cpp

index 35f4a8498074a85b2d149ea8707a1fdeabccd982..696f8f90809ee639e93375e2cd6db0ef02472e8e 100644 (file)
@@ -1868,19 +1868,23 @@ void QQuickWindowPrivate::deliverTouchEvent(QTouchEvent *event)
                 Qt::TouchPointStates states;
                 for (int i = 0; i < event->touchPoints().count(); ++i) {
                     const QTouchEvent::TouchPoint &tp = tpts.at(i);
-                    const QTouchEvent::TouchPoint &tp2 = delayedTouch->touchPoints().at(i);
-                    if (tp.id() != tp2.id()) {
+                    const QTouchEvent::TouchPoint &tpDelayed = delayedTouch->touchPoints().at(i);
+                    if (tp.id() != tpDelayed.id()) {
                         mismatch = true;
                         break;
                     }
 
-                    if (tp2.state() == Qt::TouchPointMoved && tp.state() == Qt::TouchPointStationary)
+                    if (tpDelayed.state() == Qt::TouchPointMoved && tp.state() == Qt::TouchPointStationary)
                         tpts[i].setState(Qt::TouchPointMoved);
+                    tpts[i].setLastPos(tpDelayed.lastPos());
+                    tpts[i].setLastScenePos(tpDelayed.lastScenePos());
+                    tpts[i].setLastScreenPos(tpDelayed.lastScreenPos());
+                    tpts[i].setLastNormalizedPos(tpDelayed.lastNormalizedPos());
 
                     states |= tpts.at(i).state();
                 }
 
-                // same touch event? then merge if so
+                // matching touch event? then merge the new event into the old one
                 if (!mismatch) {
                     delayedTouch->setTouchPoints(tpts);
                     delayedTouch->setTimestamp(event->timestamp());
@@ -1888,8 +1892,7 @@ void QQuickWindowPrivate::deliverTouchEvent(QTouchEvent *event)
                 }
             }
 
-            // otherwise; we need to deliver the delayed event first, and
-            // then delay this one..
+            // merging wasn't possible, so deliver the delayed event first, and then delay this one
             reallyDeliverTouchEvent(delayedTouch);
             delete delayedTouch;
             delayedTouch = new QTouchEvent(event->type(), event->device(), event->modifiers(), event->touchPointStates(), event->touchPoints());