diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-15 14:24:46 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-22 04:04:23 +0000 |
commit | 3d57afaca9d9d19e42342c270c19c86128668277 (patch) | |
tree | 6a1f955341d0e7f5b195667f781935292a5ad67f /src/quick/items/qquickflickable.cpp | |
parent | 7c06b3f9018249ca313b5dd2e6d34f3da9e8835c (diff) |
Flickable: handle the new ScrollMomentum phase in QWheelEvent
Now we can tell when macOS is sending wheel events that represent
simulated momentum, and Qt::ScrollEnd is guaranteed to mean that
scrolling actually ended. So the timer to check whether it really
ended is no longer necessary.
This reverts commit 87a4d4babe0a3d6b8a57048205eccc7105931474.
Task-number: QTBUG-63026
Task-number: QTBUG-65160
Change-Id: I0988e934b43989a3501b89d0a77eee616328ece2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r-- | src/quick/items/qquickflickable.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index c2efebf3d8..8ae5ea64a7 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -69,10 +69,6 @@ static const int FlickThreshold = 15; // will ensure the Flickable retains the grab on consecutive flicks. static const int RetainGrabVelocity = 100; -#ifdef Q_OS_OSX -static const int MovementEndingTimerInterval = 100; -#endif - // Currently std::round can't be used on Android when using ndk g++, so // use C version instead. We could just define two versions of Round, one // for float and one for double, but then only one of them would be used @@ -1497,25 +1493,24 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event) case Qt::ScrollUpdate: if (d->scrollingPhase) d->pressed = true; -#ifdef Q_OS_MACOS - // TODO eliminate this timer when ScrollMomentum has been added - d->movementEndingTimer.start(MovementEndingTimerInterval, this); -#endif + break; + case Qt::ScrollMomentum: + d->pressed = false; + d->scrollingPhase = false; + d->draggingEnding(); + event->accept(); + d->lastPosTime = -1; break; case Qt::ScrollEnd: - // TODO most of this should be done at transition to ScrollMomentum phase, - // then do what the movementEndingTimer triggers at transition to ScrollEnd phase d->pressed = false; d->scrollingPhase = false; d->draggingEnding(); event->accept(); returnToBounds(); d->lastPosTime = -1; -#ifdef Q_OS_MACOS - d->movementEndingTimer.start(MovementEndingTimerInterval, this); -#endif - return; - default: + d->stealMouse = false; + if (!d->velocityTimeline.isActive() && !d->timeline.isActive()) + movementEnding(true, true); return; } @@ -1711,14 +1706,6 @@ void QQuickFlickable::timerEvent(QTimerEvent *event) if (d->delayedPressEvent) { d->replayDelayedPress(); } - } else if (event->timerId() == d->movementEndingTimer.timerId()) { - d->movementEndingTimer.stop(); - if (!d->scrollingPhase) { - d->pressed = false; - d->stealMouse = false; - if (!d->velocityTimeline.isActive() && !d->timeline.isActive()) - movementEnding(true, true); - } } } @@ -2579,7 +2566,7 @@ void QQuickFlickablePrivate::draggingStarting() void QQuickFlickablePrivate::draggingEnding() { Q_Q(QQuickFlickable); - bool wasDragging = hData.dragging || vData.dragging; + const bool wasDragging = hData.dragging || vData.dragging; if (hData.dragging) { hData.dragging = false; emit q->draggingHorizontallyChanged(); @@ -2588,12 +2575,14 @@ void QQuickFlickablePrivate::draggingEnding() vData.dragging = false; emit q->draggingVerticallyChanged(); } - if (wasDragging && !hData.dragging && !vData.dragging) { - emit q->draggingChanged(); - emit q->dragEnded(); + if (wasDragging) { + if (!hData.dragging && !vData.dragging) { + emit q->draggingChanged(); + emit q->dragEnded(); + } + hData.inRebound = false; + vData.inRebound = false; } - hData.inRebound = false; - vData.inRebound = false; } bool QQuickFlickablePrivate::isViewMoving() const |