diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-02-16 17:21:28 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-22 10:03:20 +0100 |
commit | 6ad4a61d482d895d135a7a281115bf104e0b9a90 (patch) | |
tree | 29bc2ffc39092105efde3c21c3fa45f9187301ed /src/quick | |
parent | 7a1282a9edd8afa4645d7d449ca2ed3746fb8d71 (diff) |
Flickable shouldn't grab the mouse until it starts an effective move.
If the boundBehavior prevents the flickable from moving its content
item in response to a drag it shouldn't grab the mouse as that will
prevent a parent MouseArea or Flickable from handling the drag.
Task-number: QTBUG-29718
Change-Id: I3a1be4ed0132b91dca2fb0387ecefd39275a52da
Reviewed-by: Alan Alpert <aalpert@rim.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index c1e8dd378c..3482db0dfe 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1018,9 +1018,9 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) 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) { - 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 @@ -1031,23 +1031,20 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QQuickFlickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newY <= maxY) { + newY = maxY; + rejectY = vData.pressPos == maxY && dy < 0; + } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newY >= minY) { + newY = minY; + rejectY = vData.pressPos == minY && dy > 0; } if (!rejectY && stealMouse && dy != 0.0) { clearTimeline(); vData.move.setValue(newY); vMoved = true; } - if (overThreshold) + if (!rejectY && overThreshold) stealY = true; } } @@ -1055,9 +1052,9 @@ 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) { - 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; @@ -1065,24 +1062,22 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QQuickFlickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newX <= maxX) { + newX = maxX; + rejectX = hData.pressPos == maxX && dx < 0; + } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newX >= minX) { + newX = minX; + rejectX = hData.pressPos == minX && dx > 0; } + if (!rejectX && stealMouse && dx != 0.0) { clearTimeline(); hData.move.setValue(newX); hMoved = true; } - if (overThreshold) + if (!rejectX && overThreshold) stealX = true; } } |