diff options
-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)); |