From bc2ba337dcf1b070d436fe1fac9d10b831e31271 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 14 Jun 2023 13:53:22 +0200 Subject: [PATCH] xcb: Use QWSI::handleTabletEnterLeaveProximityEvent(.. QPointingDev* ..) We want to pass the QPointingDevice* because we've already identified it by its "system ID" (xinput device number). The other versions of handleTabletEnterProximityEvent and handleTabletLeaveProximityEvent try to identify the stylus by only its deviceType, pointerType and unique ID, which can go wrong if there are multiple tablet devices and the unique ID is not provided (as with N-trig and Wacom tablets being used at the same time). Anyway this fixes a TODO comment from 6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 Leave a "deprecated" comment by the QWSI functions that should not be used. Task-number: QTBUG-104878 Change-Id: Id9f19c60b54b7900b02d5f87b5d12f9a9189721d Reviewed-by: Volker Hilsheimer (cherry picked from commit 1a49eae776f1c40b5e22f668e30107ccbde0238b) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindowsysteminterface.h | 2 ++ src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 7b33bf3183b..29ecd656157 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -230,6 +230,8 @@ public: Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0, qreal tangentialPressure = 0, qreal rotation = 0, int z = 0, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + + // The following 4 functions are deprecated (QTBUG-114560) static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid); static void handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid); static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid); diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 22b8f437ab5..897a4299700 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1529,6 +1529,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD if (!tool && ptr[_WACSER_TOOL_SERIAL]) tool = ptr[_WACSER_TOOL_SERIAL]; + QWindow *win = nullptr; // TODO QTBUG-111400 get the position somehow, then the window // The property change event informs us which tool is in proximity or which one left proximity. if (tool) { const QPointingDevice *dev = tabletToolInstance(nullptr, tabletData->name, @@ -1537,22 +1538,19 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD tabletData->inProximity = true; tabletData->tool = dev->type(); tabletData->serialId = qint64(ptr[_WACSER_TOOL_SERIAL]); - QWindowSystemInterface::handleTabletEnterProximityEvent(ev->time, - int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId); + QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(win, ev->time, dev, true); // enter } else { tool = ptr[_WACSER_LAST_TOOL_ID]; // Workaround for http://sourceforge.net/p/linuxwacom/bugs/246/ // e.g. on Thinkpad Helix, tool ID will be 0 and serial will be 1 if (!tool) tool = ptr[_WACSER_LAST_TOOL_SERIAL]; - const QInputDevice *dev = QInputDevicePrivate::fromId(tabletData->deviceId); + auto *dev = qobject_cast(QInputDevicePrivate::fromId(tabletData->deviceId)); Q_ASSERT(dev); tabletData->tool = dev->type(); tabletData->inProximity = false; tabletData->serialId = qint64(ptr[_WACSER_LAST_TOOL_SERIAL]); - // TODO why doesn't it just take QPointingDevice* - QWindowSystemInterface::handleTabletLeaveProximityEvent(ev->time, - int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId); + QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(win, ev->time, dev, false); // leave } // TODO maybe have a hash of tabletData->deviceId to device data so we can // look up the tablet name here, and distinguish multiple tablets