aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-08-01 21:02:31 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-08-02 17:48:20 +0000
commit6008c5ded48b6d03d56bf4c4ab96177fbb185f93 (patch)
tree99dc028580b9fba6bd8cb37fc1f14b909aeb928d /tests/auto/quick/pointerhandlers
parentea195452e80e4b5a70e8c8cdf96a30581a8dd456 (diff)
MultiPointHandler::wantsPointerEvent: reset if different cand count
We always intended to "start over" with event delivery when the number of touchpoints changes. Change 48011c2dfeb83b4fe717034d4b3c353714fead48 began this process, but in addition to QQuickWindow delivering the event to all items and their handlers in reverse paint order, ignoring existing grabs, the handlers themselves have responsibility to act as if it was an initial press whenever the number of relevant touchpoints changes; and because QQuickWindow starts over, handlers do not need to rely on passive grabs to retain interest in one point at the time when a transition to a different number of points occurs. For example, DragHandler by default handles just one point, so if you press one point such that it takes a passive grab and adds that point to m_currentPoints, then you press a second finger within the bounds of the same parentItem, the DragHandler should not go on "wanting" the first point anymore, because a two-finger gesture is different, and not suitable for the DragHandler unless its maximumPointCount >= 2. Even if the second point is released, QQuickWindow will "start over" with delivery, so a multi-point handler does not need to rely on retaining a passive grab to handle the transition from two points back to one again. This also helps enable smoother transitions between different gestures: e.g. in the map.qml manual test, you can drag one finger and transition from dragging to pinching and back while the second finger is pressed, dragged and released. Change-Id: Id9b8f30029ed1ff9fd2d64a5e413a47055622083 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/pointerhandlers')
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index 1c95bb57b4..5959db0c5a 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -213,26 +213,26 @@ void tst_MptaInterop::touchesThenPinch()
// Press one more point (pinkie finger)
QPoint p4 = mpta->mapToScene(QPointF(300, 200)).toPoint();
touch.move(1, p1).move(2, p2).move(3, p3).press(4, p4).commit();
- // MPTA grabs the newly pressed point
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
+ // PinchHandler deactivates, which lets MPTA grab all the points
+ QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
- // Move some more... PinchHandler and MPTA both keep reacting
+ // Move some more... MPTA keeps reacting
for (int i = 0; i < 8; ++i) {
p1 += QPoint(4, 4);
p2 += QPoint(4, 4);
p3 += QPoint(-4, 4);
p4 += QPoint(-4, -4);
touch.move(1, p1).move(2, p2).move(3, p3).move(4, p4).commit();
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(3)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(3)->property("pressed").toBool(), true);
}
// Release the pinkie: PinchHandler acquires passive grabs on the 3 remaining points
@@ -263,13 +263,17 @@ void tst_MptaInterop::touchesThenPinch()
// Release another finger
touch.stationary(2).release(3, p3).commit();
- // Move some more: DragHandler reacts.
- // It had a passive grab this whole time; now it activates and gets an exclusive grab.
+ // Move some more: DragHandler eventually reacts.
+ int dragTookGrab = 0;
for (int i = 0; i < 8; ++i) {
p2 += QPoint(8, -8);
touch.move(2, p2).commit();
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), drag);
+ if (!dragTookGrab && pointerEvent->point(0)->exclusiveGrabber() == drag)
+ dragTookGrab = i;
}
+ qCDebug(lcPointerTests) << "drag started after" << dragTookGrab << "moves; ended with translation" << drag->translation();
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), drag);
+ QTRY_VERIFY(drag->translation().x() > 0);
touch.release(2, p2).commit();
QQuickTouchUtils::flush(window);