aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp9
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml1
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp22
3 files changed, 27 insertions, 5 deletions
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 61f97868e8..276b80abaa 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -140,17 +140,16 @@ bool QQuickTapHandler::wantsEventPoint(QQuickEventPoint *point)
}
break;
case QQuickEventPoint::Stationary:
- // Never react in any way when the point hasn't moved.
- // In autotests, the point's position may not even be correct, because
- // QTest::touchEvent(window, touchDevice).stationary(1)
- // provides no opportunity to give a position, so it ends up being random.
+ // If the point hasn't moved since last time, the return value should be the same as last time.
+ // If we return false here, QQuickPointerHandler::handlePointerEvent() will call setActive(false).
+ ret = point->pointId() == this->point().id();
break;
}
// If this is the grabber, returning false from this function will cancel the grab,
// so onGrabChanged(this, CancelGrabExclusive, point) and setPressed(false) will be called.
// But when m_gesturePolicy is DragThreshold, we don't get an exclusive grab, but
// we still don't want to be pressed anymore.
- if (!ret && point->pointId() == this->point().id() && point->state() != QQuickEventPoint::Stationary)
+ if (!ret && point->pointId() == this->point().id())
setPressed(false, true, point);
return ret;
}
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
index 042b730799..800c25c77d 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/data/Button.qml
@@ -31,6 +31,7 @@ import QtQuick 2.12
Rectangle {
id: root
property alias label: label.text
+ property alias active: tap.active
property alias pressed: tap.pressed
property bool checked: false
property alias gesturePolicy: tap.gesturePolicy
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index e77ea97518..419afed3ac 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -600,10 +600,32 @@ void tst_TapHandler::buttonsMultiTouch()
touchSeq.stationary(1).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("active").toBool());
QPoint p3 = buttonReleaseWithinBounds->mapToScene(QPointF(20, 20)).toPoint();
touchSeq.stationary(1).stationary(2).press(3, p3, window).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonReleaseWithinBounds->property("active").toBool());
+ QVERIFY(buttonWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("active").toBool());
+ QVERIFY(buttonDragThreshold->property("pressed").toBool());
+
+ // combinations of small touchpoint movements and stationary points should not cause state changes
+ p1 += QPoint(2, 0);
+ p2 += QPoint(3, 0);
+ touchSeq.move(1, p1).move(2, p2).stationary(3).commit();
+ QVERIFY(buttonDragThreshold->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("active").toBool());
+ QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonReleaseWithinBounds->property("active").toBool());
+ p3 += QPoint(4, 0);
+ touchSeq.stationary(1).stationary(2).move(3, p3).commit();
+ QVERIFY(buttonDragThreshold->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonWithinBounds->property("active").toBool());
+ QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool());
+ QVERIFY(buttonReleaseWithinBounds->property("active").toBool());
// can release top button and press again: others stay pressed the whole time
touchSeq.stationary(2).stationary(3).release(1, p1, window).commit();