From: Tang Haixiang Date: Fri, 18 Jun 2021 06:29:01 +0000 (+0800) Subject: xcb: Delete touch points without target windows X-Git-Url: https://codereview.qt-project.org/gitweb?p=qt%2Fqtbase.git;a=commitdiff_plain;h=b0de19a831c4abdeddd062f973cc8f501aa5165d;hp=567340e1222d6be354b17ec66bf5f23066d4fa82 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 (cherry picked from commit efc02f9cc301f98c77079adae026ffd07f50d5ab) Reviewed-by: Qt Cherry-pick Bot --- diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3061,7 +3061,7 @@ void QGuiApplicationPrivate::processTouc 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 = touchPoints.first().id(); for (const auto &touchPoint : touchPoints) { if (touchPoint.id() == m_fakeMouseSourcePointId) { diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 2fae965053fd..58cd79a7868a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -782,8 +782,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) {