diff options
-rw-r--r-- | examples/quick/shared/LauncherList.qml | 1 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 10 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler_p.h | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp | 6 |
4 files changed, 13 insertions, 5 deletions
diff --git a/examples/quick/shared/LauncherList.qml b/examples/quick/shared/LauncherList.qml index ee8fc3984e..82fcf0c194 100644 --- a/examples/quick/shared/LauncherList.qml +++ b/examples/quick/shared/LauncherList.qml @@ -181,6 +181,7 @@ Rectangle { TapHandler { id: tapHandler enabled: root.activePageCount > 0 + gesturePolicy: TapHandler.ReleaseWithinBounds onTapped: { pageContainer.children[pageContainer.children.length - 1].exit() } diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index 5c1b59cf61..43c761f5fd 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -78,6 +78,8 @@ bool QQuickTapHandler::wantsEventPoint(const QPointerEvent *event, const QEventP bool ret = false; bool overThreshold = d_func()->dragOverThreshold(point); if (overThreshold && m_gesturePolicy != DragWithinBounds) { + if (m_longPressTimer.isActive()) + qCDebug(lcTapHandler) << objectName() << "drag threshold exceeded"; m_longPressTimer.stop(); m_holdTimer.invalidate(); } @@ -176,6 +178,7 @@ void QQuickTapHandler::timerEvent(QTimerEvent *event) if (event->timerId() == m_longPressTimer.timerId()) { m_longPressTimer.stop(); qCDebug(lcTapHandler) << objectName() << "longPressed"; + m_longPressed = true; emit longPressed(); } else if (event->timerId() == m_doubleTapTimer.timerId()) { m_doubleTapTimer.stop(); @@ -364,7 +367,9 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QPointerEvent *event, setExclusiveGrab(event, point, press); } if (!cancel && !press && parentContains(point)) { - if (point.timeHeld() < longPressThreshold()) { + if (m_longPressed) { + qCDebug(lcTapHandler) << objectName() << "long press threshold" << longPressThreshold() << "exceeded:" << point.timeHeld(); + } else { // Assuming here that pointerEvent()->timestamp() is in ms. const quint64 ts = event->timestamp(); const quint64 interval = ts - m_lastTapTimestamp; @@ -410,10 +415,9 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QPointerEvent *event, m_lastTapTimestamp = ts; m_lastTapPos = point.scenePosition(); - } else { - qCDebug(lcTapHandler) << objectName() << "tap threshold" << longPressThreshold() << "exceeded:" << point.timeHeld(); } } + m_longPressed = false; emit pressedChanged(); if (!press && m_gesturePolicy != DragThreshold) { // on release, ungrab after emitting changed signals diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h index 8c6b6d162d..5e57e81a29 100644 --- a/src/quick/handlers/qquicktaphandler_p.h +++ b/src/quick/handlers/qquicktaphandler_p.h @@ -109,6 +109,7 @@ private: GesturePolicy m_gesturePolicy = GesturePolicy::DragThreshold; ExclusiveSignals m_exclusiveSignals = NotExclusive; bool m_pressed = false; + bool m_longPressed = false; static quint64 m_multiTapInterval; static int m_mouseMultiClickDistanceSquared; diff --git a/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp b/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp index fc457666e6..2302e216f8 100644 --- a/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp +++ b/tests/auto/quick/qquickdeliveryagent/tst_qquickdeliveryagent.cpp @@ -179,7 +179,8 @@ void tst_qquickdeliveryagent::passiveGrabberOrder() QPoint pos(75, 75); QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, pos); - QTest::qWait(1000); + QTRY_VERIFY(rootTap->isPressed()); + QTRY_VERIFY(subsceneTap->isPressed()); auto devPriv = QPointingDevicePrivate::get(QPointingDevice::primaryPointingDevice()); const auto &persistentPoint = devPriv->activePoints.values().first(); qCDebug(lcTests) << "passive grabbers" << persistentPoint.passiveGrabbers << "contexts" << persistentPoint.passiveGrabbersContext; @@ -189,7 +190,8 @@ void tst_qquickdeliveryagent::passiveGrabberOrder() QCOMPARE(persistentPoint.passiveGrabbers.last(), rootTap); QTest::mouseRelease(&view, Qt::LeftButton); - QTest::qWait(100); + QTRY_COMPARE(rootTap->isPressed(), false); + QTRY_COMPARE(subsceneTap->isPressed(), false); // QQuickWindow::event() has failsafe: clear all grabbers after release QCOMPARE(persistentPoint.passiveGrabbers.size(), 0); |