diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-07-01 15:17:18 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-07-01 20:25:56 +0200 |
commit | 3372e1db14679840844d64e9e3de8aa567828939 (patch) | |
tree | fcce2b190f80c050b2ae528cbdd8cc8827ff48d5 /src/plugins/platforms/cocoa | |
parent | 60c69b4da52b4b90e74af569c859c992e8e910fe (diff) |
Cocoa: deal with unexpected tablet events without proximity
If the user has a Wacom stylus in proximity of the tablet already
(perhaps left it lying on the tablet) and starts a Qt application, we
don't get to see a proximity enter event, so a lot of device information
is missing; nevertheless, creating a stop-gap device (with ID 0, type
Unknown) makes it possible to get basic QTabletEvents with pressure,
until the next time the stylus leaves and comes back into proximity.
Pick-to: 6.4
Fixes: QTBUG-65559
Change-Id: Ibacbdb78461c0b62d4040c80d210a1b06074e952
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_tablet.mm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_tablet.mm b/src/plugins/platforms/cocoa/qnsview_tablet.mm index 72e1b2d78f..4c6e351b3f 100644 --- a/src/plugins/platforms/cocoa/qnsview_tablet.mm +++ b/src/plugins/platforms/cocoa/qnsview_tablet.mm @@ -34,14 +34,18 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceMap, devicesInProximity) // We use devicesInProximity because deviceID is typically 0, // so QInputDevicePrivate::fromId() won't work. - const auto *device = devicesInProximity->value(theEvent.deviceID); - if (!device) { - // Error: Unknown tablet device. Qt also gets into this state - // when running on a VM. This appears to be harmless; don't - // print a warning. - return false; + const auto deviceId = theEvent.deviceID; + const auto *device = devicesInProximity->value(deviceId); + if (!device && deviceId == 0) { + // Application started up with stylus in proximity already, so we missed the proximity event? + // Create a generic tablet device for now. + device = tabletToolInstance(theEvent); + devicesInProximity->insert(deviceId, device); } + if (Q_UNLIKELY(!device)) + return false; + bool down = (eventType != NSEventTypeMouseMoved); qreal pressure; |