Transform the velocity taken from touch event
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Wed, 2 May 2012 11:15:13 +0000 (14:15 +0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 2 May 2012 11:38:30 +0000 (13:38 +0200)
Change-Id: Ib90531f4526fad0c51b2f2e1e7c5ebcff4f5dec8
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/quick/items/qquickcanvas.cpp

index 11b304d..17f9947 100644 (file)
@@ -469,11 +469,13 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event)
 
 void QQuickCanvasPrivate::transformTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints, const QTransform &transform)
 {
+    QMatrix4x4 transformMatrix(transform);
     for (int i=0; i<touchPoints.count(); i++) {
         QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
         touchPoint.setRect(transform.mapRect(touchPoint.sceneRect()));
         touchPoint.setStartPos(transform.map(touchPoint.startScenePos()));
         touchPoint.setLastPos(transform.map(touchPoint.lastScenePos()));
+        touchPoint.setVelocity(transformMatrix.mapVector(touchPoint.velocity()).toVector2D());
     }
 }
 
@@ -1133,7 +1135,7 @@ bool QQuickCanvasPrivate::deliverMouseEvent(QMouseEvent *event)
                                 event->button(), event->buttons(), event->modifiers());
         QQuickMouseEventEx *eventEx = QQuickMouseEventEx::extended(event);
         if (eventEx) {
-            me.setVelocity(eventEx->velocity());
+            me.setVelocity(QMatrix4x4(transform).mapVector(eventEx->velocity()).toVector2D());
             me.setCapabilities(eventEx->capabilities());
         }
         me.setTimestamp(event->timestamp());