diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-03-12 14:05:32 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-19 02:20:05 +0100 |
commit | ea8b11259ad68a8ff44708786ecf54e5a8a272d8 (patch) | |
tree | e53b929afaa993b38052bcc505badff81c66ac9e | |
parent | fb8bc2ab5f834dc25bc6178776f67facaf76d698 (diff) |
Fix jump and property changes on first move when dragging a Flickable.
Fixes a regression introduced by https://codereview.qt-project.org/48690
whereby on the first mouse move the contentItem was moved the total
distance from the touch point to where the drag distance was exceeded.
For large drag thresholds this causes a noticeable jump. Reverting the
dragStartOffset portion of that change fixes the regression.
That same change was also resposible for the property update regression
https://codereview.qt-project.org/49768 attempted to fix. That change
is also reverted as it was unnecessary and may have introduced some
regressions of its own.
Task-number: QTBUG-30032
Change-Id: I7723b459cc5a6a0731893aeb6332d00cad1bd79b
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 27 | ||||
-rw-r--r-- | tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp | 4 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 9346c79847..dd7357822a 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1014,20 +1014,14 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) bool prevHMoved = hMoved; bool prevVMoved = vMoved; - bool moveY = false; - bool moveX = false; - - qreal newY = 0; - qreal newX = 0; - qint64 elapsedSincePress = computeCurrentTime(event) - lastPressTime; if (q->yflick()) { qreal dy = event->localPos().y() - pressPos.y(); bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event); - if (vData.dragStartOffset == 0) - vData.dragStartOffset = dy; if (overThreshold || elapsedSincePress > 200) { - newY = dy + vData.pressPos - vData.dragStartOffset; + if (!vMoved) + vData.dragStartOffset = dy; + qreal newY = dy + vData.pressPos - vData.dragStartOffset; // Recalculate bounds in case margins have changed, but use the content // size estimate taken at the start of the drag in case the drag causes // the estimate to be altered @@ -1047,8 +1041,8 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) } if (!rejectY && stealMouse && dy != 0.0) { clearTimeline(); + vData.move.setValue(newY); vMoved = true; - moveY = true; } if (!rejectY && overThreshold) stealY = true; @@ -1058,10 +1052,10 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (q->xflick()) { qreal dx = event->localPos().x() - pressPos.x(); bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event); - if (hData.dragStartOffset == 0) - hData.dragStartOffset = dx; if (overThreshold || elapsedSincePress > 200) { - newX = dx + hData.pressPos - hData.dragStartOffset; + if (!hMoved) + hData.dragStartOffset = dx; + qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = hData.dragMinBound + hData.startMargin; const qreal maxX = hData.dragMaxBound - hData.endMargin; if (newX > minX) @@ -1079,8 +1073,8 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (!rejectX && stealMouse && dx != 0.0) { clearTimeline(); + hData.move.setValue(newX); hMoved = true; - moveX = true; } if (!rejectX && overThreshold) @@ -1108,11 +1102,6 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) q->movementStarting(); } - if (moveY) - vData.move.setValue(newY); - if (moveX) - hData.move.setValue(newX); - qint64 currentTimestamp = computeCurrentTime(event); qreal elapsed = qreal(currentTimestamp - (lastPos.isNull() ? lastPressTime : lastPosTime)) / 1000.; if (elapsed <= 0) diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index a4bc92449b..055facc9e1 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -807,8 +807,8 @@ void tst_QQuickMouseArea::preventStealing() // Flickable content should have moved. - QCOMPARE(flickable->contentX(), 22.); - QCOMPARE(flickable->contentY(), 22.); + QCOMPARE(flickable->contentX(), 11.); + QCOMPARE(flickable->contentY(), 11.); QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 50)); |