From 1500d2283e17be72226b2960a79039254887977f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 20 Feb 2019 13:55:03 +0100 Subject: Clear only one device from g_pointIdMap when all points released MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new test tst_QTouchEvent::touchOnMultipleTouchscreens() needs the touchpoint IDs to be predictable, but another test currently has a QEXPECT_FAIL; without release events, g_pointIdMap continued to hold the touchpoints that were there when the test failed. So it's necessary to add QWindowSystemInterfacePrivate::clearPointIdMap() to be able to call it in the test cleanup function. Fixes: QTBUG-73830 Change-Id: Ia6a70d028be95cd2b6676db6363ec408c0b116bc Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qwindowsysteminterface.cpp | 20 ++++++++++++++++++-- src/gui/kernel/qwindowsysteminterface_p.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 5b32405f5e..7067ece1d8 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -695,13 +695,29 @@ QList } if (states == Qt::TouchPointReleased) { - g_nextPointId = 1; - g_pointIdMap->clear(); + // All points on deviceId have been released. + // Remove all points associated with that device from g_pointIdMap. + // (On other devices, some touchpoints might still be pressed. + // But this function is only called with points from one device at a time.) + for (auto it = g_pointIdMap->begin(); it != g_pointIdMap->end();) { + if (it.key() >> 32 == quint64(deviceId)) + it = g_pointIdMap->erase(it); + else + ++it; + } + if (g_pointIdMap->isEmpty()) + g_nextPointId = 1; } return touchPoints; } +void QWindowSystemInterfacePrivate::clearPointIdMap() +{ + g_pointIdMap->clear(); + g_nextPointId = 1; +} + QList QWindowSystemInterfacePrivate::toNativeTouchPoints(const QList& pointList, const QWindow *window) diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 9cb4e191cc..cea02fb8b7 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -537,6 +537,7 @@ public: static QList toNativeTouchPoints(const QList& pointList, const QWindow *window); + static void clearPointIdMap(); static void installWindowSystemEventHandler(QWindowSystemEventHandler *handler); static void removeWindowSystemEventhandler(QWindowSystemEventHandler *handler); -- cgit v1.2.3