diff options
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 12 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 51 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index c6376b2647..a19eebfb7c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2294,6 +2294,18 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (w->d_func()->blockedByModalWindow) { // a modal window is blocking this window, don't allow touch events through + + // QTBUG-37371 temporary fix; TODO: revisit in 5.4 when we have a forwarding solution + if (eventType == QEvent::TouchEnd) { + // but don't leave dangling state: e.g. + // QQuickWindowPrivate::itemForTouchPointId needs to be cleared. + QTouchEvent touchEvent(QEvent::TouchCancel, + e->device, + e->modifiers); + touchEvent.setTimestamp(e->timestamp); + touchEvent.setWindow(w); + QGuiApplication::sendSpontaneousEvent(w, &touchEvent); + } continue; } diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 7e6313295b..da142c80a6 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -71,6 +71,7 @@ private slots: void mouseToTouchLoop(); void touchCancel(); void touchCancelWithTouchToMouse(); + void touchInterruptedByPopup(); void orientation(); void sizes(); void close(); @@ -772,6 +773,56 @@ void tst_QWindow::touchCancelWithTouchToMouse() QTRY_COMPARE(window.mouseReleaseButton, 0); } +void tst_QWindow::touchInterruptedByPopup() +{ + InputTestWindow window; + window.setGeometry(80, 80, 200, 200); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QList<QWindowSystemInterface::TouchPoint> points; + QWindowSystemInterface::TouchPoint tp1; + tp1.id = 1; + + // Start a touch. + tp1.state = Qt::TouchPointPressed; + tp1.area = QRect(10, 10, 4, 4); + points << tp1; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.touchEventType, QEvent::TouchBegin); + QTRY_COMPARE(window.touchPressedCount, 1); + + // Launch a popup window + InputTestWindow popup; + popup.setFlags(Qt::Popup); + popup.setModality(Qt::WindowModal); + popup.setWidth(160); + popup.setHeight(160); + popup.setTransientParent(&window); + popup.show(); + QVERIFY(QTest::qWaitForWindowExposed(&popup)); + + // Send a move -> will not be delivered to the original window + // (TODO verify where it is forwarded, after we've defined that) + QTRY_COMPARE(window.touchMovedCount, 0); + points[0].state = Qt::TouchPointMoved; + tp1.area.adjust(2, 2, 2, 2); + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.touchMovedCount, 0); + + // Send a touch end -> will not be delivered to the original window + QTRY_COMPARE(window.touchReleasedCount, 0); + points[0].state = Qt::TouchPointReleased; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.touchReleasedCount, 0); + + // Due to temporary fix for QTBUG-37371: the original window should receive a TouchCancel + QTRY_COMPARE(window.touchEventType, QEvent::TouchCancel); +} + void tst_QWindow::orientation() { qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation"); |