Skip to content

Commit a6531b7

Browse files
JWWTSLZeno-sole
authored andcommitted
fix: 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. Upstream: https://codereview.qt-project.org/c/qt/qtbase/+/412280
1 parent ad4287b commit a6531b7

File tree

3 files changed

+115
-2
lines changed

3 files changed

+115
-2
lines changed

debian/changelog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
qtbase-opensource-src (5.15.8-1+deepin7) UNRELEASED; urgency=medium
1+
qtbase-opensource-src (5.15.8-1+deepin8) unstable; urgency=medium
22

33
* Fix Clear WA_UnderMouse attribute when widget gets hidden
44
-- QTBUG-104805-QColorDialog-Buttons-are-highlighted-incorrectly.patch
@@ -10,8 +10,10 @@ qtbase-opensource-src (5.15.8-1+deepin7) UNRELEASED; urgency=medium
1010
-- Fix-QTextEdit-or-QPlanTextEdit-palette-not-updated.patch
1111
* remove fix_action_distance_lineedit.patch, and allow styles to
1212
control the margin around icons in QLineEdit.
13+
* xcb: Delete touch points without target windows
14+
-- Xcb-Delete-touch-points-without-target-windows.patch
1315

14-
-- Tian ShiLin <[email protected]> Fri, 19 Apr 2024 10:28:01 +0800
16+
-- Tian ShiLin <[email protected]> Fri, 17 May 2024 17:00:44 +0800
1517

1618
qtbase-opensource-src (5.15.8-1+deepin6) unstable; urgency=medium
1719

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Index: qtbase-opensource-src/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
2+
===================================================================
3+
--- qtbase-opensource-src.orig/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
4+
+++ qtbase-opensource-src/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
5+
@@ -591,8 +591,12 @@ void QXcbConnection::xi2HandleEvent(xcb_
6+
event->event_type, xiDeviceEvent->sequence, xiDeviceEvent->detail,
7+
fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y),
8+
fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event);
9+
- if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event))
10+
+ if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) {
11+
xi2ProcessTouch(xiDeviceEvent, platformWindow);
12+
+ } else { // When the window cannot be matched, delete it from touchPoints
13+
+ if (TouchDeviceData *dev = touchDeviceForId(xiDeviceEvent->sourceid))
14+
+ dev->touchPoints.remove((xiDeviceEvent->detail % INT_MAX));
15+
+ }
16+
break;
17+
}
18+
} else if (xiEnterEvent && !xi2MouseEventsDisabled() && eventListener) {
19+
Index: qtbase-opensource-src/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
20+
===================================================================
21+
--- qtbase-opensource-src.orig/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
22+
+++ qtbase-opensource-src/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
23+
@@ -1113,8 +1113,9 @@ void tst_QWindow::touchToMouseTranslatio
24+
QVERIFY(QTest::qWaitForWindowExposed(&window));
25+
26+
QList<QWindowSystemInterface::TouchPoint> points;
27+
- QWindowSystemInterface::TouchPoint tp1, tp2;
28+
+ QWindowSystemInterface::TouchPoint tp1, tp2, tp3;
29+
const QRectF pressArea(101, 102, 4, 4);
30+
+ const QRectF pressArea1(107, 110, 4, 4);
31+
const QRectF moveArea(105, 108, 4, 4);
32+
tp1.id = 1;
33+
tp1.state = Qt::TouchPointPressed;
34+
@@ -1122,6 +1123,9 @@ void tst_QWindow::touchToMouseTranslatio
35+
tp2.id = 2;
36+
tp2.state = Qt::TouchPointPressed;
37+
points << tp1 << tp2;
38+
+ tp3.id = 3;
39+
+ tp3.state = Qt::TouchPointPressed;
40+
+ tp3.area = QHighDpi::toNativePixels(pressArea1, &window);
41+
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
42+
// Now an update but with changed list order. The mouse event should still
43+
// be generated from the point with id 1.
44+
@@ -1194,6 +1198,40 @@ void tst_QWindow::touchToMouseTranslatio
45+
points[0].state = Qt::TouchPointReleased;
46+
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
47+
QCoreApplication::processEvents();
48+
+ points.clear();
49+
+ points.append(tp1);
50+
+ points[0].state = Qt::TouchPointReleased;
51+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
52+
+ QCoreApplication::processEvents();
53+
+ QTRY_COMPARE(window.mouseReleaseButton, 1);
54+
+
55+
+ points.clear();
56+
+ points.append(tp1);
57+
+ points[0].state = Qt::TouchPointPressed;
58+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
59+
+ QCoreApplication::processEvents();
60+
+ points.clear();
61+
+ points.append(tp2);
62+
+ points[0].state = Qt::TouchPointPressed;
63+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
64+
+ QCoreApplication::processEvents();
65+
+ points.clear();
66+
+ points.append(tp3);
67+
+ points[0].state = Qt::TouchPointPressed;
68+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
69+
+ QCoreApplication::processEvents();
70+
+ QTRY_COMPARE(window.mousePressButton, 1);
71+
+
72+
+ points.clear();
73+
+ points.append(tp2);
74+
+ points[0].state = Qt::TouchPointReleased;
75+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
76+
+ QCoreApplication::processEvents();
77+
+ points.clear();
78+
+ points.append(tp3);
79+
+ points[0].state = Qt::TouchPointReleased;
80+
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
81+
+ QCoreApplication::processEvents();
82+
points.clear();
83+
points.append(tp1);
84+
points[0].state = Qt::TouchPointReleased;
85+
Index: qtbase-opensource-src/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
86+
===================================================================
87+
--- qtbase-opensource-src.orig/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
88+
+++ qtbase-opensource-src/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
89+
@@ -297,7 +297,7 @@ void tst_QGestureRecognizer::swipeGestur
90+
91+
// Press point #3
92+
points.append(points.last() + fingerDistance);
93+
- swipeSequence.press(points.size() - 1, points.last(), &widget);
94+
+ swipeSequence.stationary(0).stationary(1).press(points.size() - 1, points.last(), &widget);
95+
swipeSequence.commit();
96+
Q_ASSERT(points.size() == swipePoints);
97+
98+
Index: qtbase-opensource-src/src/gui/kernel/qguiapplication.cpp
99+
===================================================================
100+
--- qtbase-opensource-src.orig/src/gui/kernel/qguiapplication.cpp
101+
+++ qtbase-opensource-src/src/gui/kernel/qguiapplication.cpp
102+
@@ -3064,7 +3064,7 @@ void QGuiApplicationPrivate::processTouc
103+
QEvent::Type mouseEventType = QEvent::MouseMove;
104+
Qt::MouseButton button = Qt::NoButton;
105+
Qt::MouseButtons buttons = Qt::LeftButton;
106+
- if (eventType == QEvent::TouchBegin && m_fakeMouseSourcePointId < 0)
107+
+ if (eventType == QEvent::TouchBegin || m_fakeMouseSourcePointId < 0)
108+
m_fakeMouseSourcePointId = touchPoints.first().id();
109+
for (const auto &touchPoint : touchPoints) {
110+
if (touchPoint.id() == m_fakeMouseSourcePointId) {

debian/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ QTBUG-104805-QColorDialog-Buttons-are-highlighted-incorrectly.patch
7272
QTBUG-89082-The-previous-tips-is-still-displayed-when-mouse-move-to-another-Action-without-tips.patch
7373
QMenu-toggle-action-submenu-disappears-immediately.patch
7474
Fix-QTextEdit-or-QPlanTextEdit-palette-not-updated.patch
75+
Xcb-Delete-touch-points-without-target-windows.patch

0 commit comments

Comments
 (0)