diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-04-03 11:37:03 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-05-22 19:12:12 +0000 |
commit | 48011c2dfeb83b4fe717034d4b3c353714fead48 (patch) | |
tree | 836196ff3c97c7085b5c9e7a4be052ad02759b33 /src/quick/handlers/qquicktaphandler.cpp | |
parent | a09b2f6fcd087e849f4e766a03c1ab47ae49d0d7 (diff) |
Start over with event delivery when touchpoint releases occur
The new rule is that when the number of touchpoints changes, we start
over with event delivery as if the touch had just begun, to give more
opportunities to hand off processing from one item or handler to
another. And MultiPointTouchArea can now handle the handoff:
for example in tests/manual/pointer/pinchDragFlingMPTA.qml when the
user is pressing three fingers, the PinchHandler is active; when the
user then lifts one finger, the MPTA can resume handling the two
remaining touchpoints as if they were just pressed.
The change in QQuickMultiPointerHandler::wantsPointerEvent is both
a behavior change and an optimization: released points aren't eligible;
but if some points are released, then pressed, updated and stationary
points are all eligible. And, figure this out without looping over the
points twice.
Change-Id: I26b7593de8e72b471adfec4a4482dd87a8288442
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquicktaphandler.cpp')
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index f79dbb266a..d73e9fd100 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -270,7 +270,7 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi else setExclusiveGrab(point, press); } - if (!cancel && !press) { + if (!cancel && !press && parentContains(point)) { if (point->timeHeld() < longPressThreshold()) { // Assuming here that pointerEvent()->timestamp() is in ms. qreal ts = point->pointerEvent()->timestamp() / 1000.0; @@ -301,8 +301,9 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi void QQuickTapHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) { QQuickPointerSingleHandler::onGrabChanged(grabber, stateChange, point); - if (grabber == this && (stateChange == QQuickEventPoint::CancelGrabExclusive || stateChange == QQuickEventPoint::CancelGrabPassive)) - setPressed(false, true, point); + bool isCanceled = stateChange == QQuickEventPoint::CancelGrabExclusive || stateChange == QQuickEventPoint::CancelGrabPassive; + if (grabber == this && (isCanceled || point->state() == QQuickEventPoint::Released)) + setPressed(false, isCanceled, point); } void QQuickTapHandler::connectPreRenderSignal(bool conn) |