diff options
4 files changed, 46 insertions, 4 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e08e970aa4..a8ec2c0540 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2984,7 +2984,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QEvent::Type mouseEventType = QEvent::MouseMove; Qt::MouseButton button = Qt::NoButton; Qt::MouseButtons buttons = Qt::LeftButton; - if (eventType == QEvent::TouchBegin && m_fakeMouseSourcePointId < 0) { + if (eventType == QEvent::TouchBegin || m_fakeMouseSourcePointId < 0) { m_fakeMouseSourcePointId = touchEvent.point(0).id(); qCDebug(lcPtrDispatch) << "synthesizing mouse events from touchpoint" << m_fakeMouseSourcePointId; } diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 8aff250b02..8cb4e5d603 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -748,8 +748,12 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) event->event_type, xiDeviceEvent->sequence, xiDeviceEvent->detail, fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y), fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event); - if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) + if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) { xi2ProcessTouch(xiDeviceEvent, platformWindow); + } else { // When the window cannot be matched, delete it from touchPoints + if (TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid)) + dev->touchPoints.remove((xiDeviceEvent->detail % INT_MAX)); + } break; } } else if (xiEnterEvent && eventListener) { diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 1cf0c43d98..dafa69fb96 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1157,14 +1157,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 = QEventPoint::State::Pressed; tp1.area = QHighDpi::toNativePixels(pressArea, &window); tp2.id = 2; tp2.state = QEventPoint::State::Pressed; + tp3.id = 3; + tp3.state = QEventPoint::State::Pressed; + 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 @@ -1246,6 +1250,40 @@ void tst_QWindow::touchToMouseTranslation() QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); QTRY_COMPARE(window.mouseReleaseButton, 1); + + points.clear(); + points.append(tp1); + points[0].state = QEventPoint::State::Pressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp2); + points[0].state = QEventPoint::State::Pressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp3); + points[0].state = QEventPoint::State::Pressed; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.mousePressButton, 1); + + points.clear(); + points.append(tp2); + points[0].state = QEventPoint::State::Released; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp3); + points[0].state = QEventPoint::State::Released; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + points.clear(); + points.append(tp1); + points[0].state = QEventPoint::State::Released; + QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); + QCoreApplication::processEvents(); + QTRY_COMPARE(window.mouseReleaseButton, 1); } void tst_QWindow::touchToMouseTranslationForDevices() diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp index 6d5282732a..87e0290473 100644 --- a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -269,7 +269,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); |