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
6589f2ed0c

Leave a "deprecated" comment by the QWSI functions that should not
be used.

Pick-to: 6.6 6.5
Task-number: QTBUG-104878
Change-Id: Id9f19c60b54b7900b02d5f87b5d12f9a9189721d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Shawn Rutledge 2023-06-14 13:53:22 +02:00
parent b26cdbd877
commit 1a49eae776
2 changed files with 6 additions and 6 deletions

View File

@ -230,6 +230,8 @@ public:
Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0, Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
qreal tangentialPressure = 0, qreal rotation = 0, int z = 0, qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
Qt::KeyboardModifiers modifiers = Qt::NoModifier); 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 bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
static void handleTabletEnterProximityEvent(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); static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);

View File

@ -1529,6 +1529,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
if (!tool && ptr[_WACSER_TOOL_SERIAL]) if (!tool && ptr[_WACSER_TOOL_SERIAL])
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. // The property change event informs us which tool is in proximity or which one left proximity.
if (tool) { if (tool) {
const QPointingDevice *dev = tabletToolInstance(nullptr, tabletData->name, const QPointingDevice *dev = tabletToolInstance(nullptr, tabletData->name,
@ -1537,22 +1538,19 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
tabletData->inProximity = true; tabletData->inProximity = true;
tabletData->tool = dev->type(); tabletData->tool = dev->type();
tabletData->serialId = qint64(ptr[_WACSER_TOOL_SERIAL]); tabletData->serialId = qint64(ptr[_WACSER_TOOL_SERIAL]);
QWindowSystemInterface::handleTabletEnterProximityEvent(ev->time, QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(win, ev->time, dev, true); // enter
int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId);
} else { } else {
tool = ptr[_WACSER_LAST_TOOL_ID]; tool = ptr[_WACSER_LAST_TOOL_ID];
// Workaround for http://sourceforge.net/p/linuxwacom/bugs/246/ // Workaround for http://sourceforge.net/p/linuxwacom/bugs/246/
// e.g. on Thinkpad Helix, tool ID will be 0 and serial will be 1 // e.g. on Thinkpad Helix, tool ID will be 0 and serial will be 1
if (!tool) if (!tool)
tool = ptr[_WACSER_LAST_TOOL_SERIAL]; tool = ptr[_WACSER_LAST_TOOL_SERIAL];
const QInputDevice *dev = QInputDevicePrivate::fromId(tabletData->deviceId); auto *dev = qobject_cast<const QPointingDevice *>(QInputDevicePrivate::fromId(tabletData->deviceId));
Q_ASSERT(dev); Q_ASSERT(dev);
tabletData->tool = dev->type(); tabletData->tool = dev->type();
tabletData->inProximity = false; tabletData->inProximity = false;
tabletData->serialId = qint64(ptr[_WACSER_LAST_TOOL_SERIAL]); tabletData->serialId = qint64(ptr[_WACSER_LAST_TOOL_SERIAL]);
// TODO why doesn't it just take QPointingDevice* QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(win, ev->time, dev, false); // leave
QWindowSystemInterface::handleTabletLeaveProximityEvent(ev->time,
int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId);
} }
// TODO maybe have a hash of tabletData->deviceId to device data so we can // TODO maybe have a hash of tabletData->deviceId to device data so we can
// look up the tablet name here, and distinguish multiple tablets // look up the tablet name here, and distinguish multiple tablets