diff options
author | Tang Haixiang <tanghaixiang@uniontech.com> | 2021-06-18 14:29:01 +0800 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2022-09-16 19:53:37 +0200 |
commit | 7380edaeb81622d3685fb989809d03a5f2d95cfa (patch) | |
tree | ef04f6dc00623b26031067facb8580adfcb197d9 /tests | |
parent | 678928f4af63b3c4cddde79b0966dba6d22728d1 (diff) |
xcb: Delete touch points without target windows
When XCB_INPUT_TOUCH_BEGIN closes a popup, we then receive
XCB_INPUT_TOUCH_END, and cannot find a target window (because it's
destroyed). If we don't deliver it, we need to at least clear the
stored point from QPointingDevicePrivate::activePoints. Then when
we deliver the next touch press, m_fakeMouseSourcePointId also
needs to be reset.
It's now even more paramount that autotests (and real-world
touchscreens) must never omit any active touchpoint from a touch event.
If a point doesn't move, it must be included in the QTouchEvent, with
Stationary state. If not, QGuiApp::processTouchEvent() could generate
multiple TouchBegin events in a row, which gets other bits of logic
confused, here and there.
Fixes: QTBUG-94557
Fixes: QTBUG-98519
Fixes: QTBUG-102751
Fixes: QTBUG-103706
Change-Id: Ia95e410a2bb8bc7784aa5d296fac2b89e53a9f55
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit efc02f9cc301f98c77079adae026ffd07f50d5ab)
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 44 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp | 2 |
2 files changed, 44 insertions, 2 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 2292462046..682b277470 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1113,14 +1113,18 @@ void tst_QWindow::touchToMouseTranslation() QVERIFY(QTest::qWaitForWindowExposed(&window)); QList<QWindowSystemInterface::TouchPoint> points; - QWindowSystemInterface::TouchPoint tp1, tp2; + QWindowSystemInterface::TouchPoint tp1, tp2, tp3; const QRectF pressArea(101, 102, 4, 4); + const QRectF pressArea1(107, 110, 4, 4); const QRectF moveArea(105, 108, 4, 4); tp1.id = 1; tp1.state = Qt::TouchPointPressed; tp1.area = QHighDpi::toNativePixels(pressArea, &window); tp2.id = 2; tp2.state = Qt::TouchPointPressed; + tp3.id = 3; + tp3.state = Qt::TouchPointPressed; + tp3.area = QHighDpi::toNativePixels(pressArea1, &window); points << tp1 << tp2; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); // Now an update but with changed list order. The mouse event should still @@ -1185,6 +1189,8 @@ void tst_QWindow::touchToMouseTranslation() points.clear(); points.append(tp1); points[0].state = Qt::TouchPointPressed; + points.append(tp2); + points[1].state = Qt::TouchPointStationary; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); QTRY_COMPARE(window.mousePressButton, 1); @@ -1192,6 +1198,42 @@ void tst_QWindow::touchToMouseTranslation() points.clear(); points.append(tp2); points[0].state = Qt::TouchPointReleased; + points.append(tp1); + points[1].state = Qt::TouchPointStationary; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp1); + points[0].state = Qt::TouchPointReleased; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.mouseReleaseButton, 1); + + points.clear(); + points.append(tp1); + points[0].state = Qt::TouchPointPressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp2); + points[0].state = Qt::TouchPointPressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp3); + points[0].state = Qt::TouchPointPressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.mousePressButton, 1); + + points.clear(); + points.append(tp2); + points[0].state = Qt::TouchPointReleased; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp3); + points[0].state = Qt::TouchPointReleased; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); points.clear(); diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp index bcf48c21df..db71e86d7e 100644 --- a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -297,7 +297,7 @@ void tst_QGestureRecognizer::swipeGesture() // Press point #3 points.append(points.last() + fingerDistance); - swipeSequence.press(points.size() - 1, points.last(), &widget); + swipeSequence.stationary(0).stationary(1).press(points.size() - 1, points.last(), &widget); swipeSequence.commit(); Q_ASSERT(points.size() == swipePoints); |