QXcbConnection::xi2ReportTabletEvent(): get device, check capabilities
In Qt 5, RotationStylus was a device type; in Qt 6, we have the Rotation capability flag instead. The event does not tell us whether rotation is valid or not, so to distinguish a valid zero value from a zero that means it's absent, we need to check device capabilities. Anyway it's better to get the QPointingDevice instance earlier and call the newer version of QWindowSystemInterface::handleTabletEvent(). Fixes: QTBUG-104877 Change-Id: I896c02727d586381489f79fd4ebea3451adfa403 Pick-to: 6.2 6.3 6.4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
03a691cecb
commit
6749d69a15
@ -1550,6 +1550,9 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
|
||||
double pressure = 0, rotation = 0, tangentialPressure = 0;
|
||||
int xTilt = 0, yTilt = 0;
|
||||
static const bool useValuators = !qEnvironmentVariableIsSet("QT_XCB_TABLET_LEGACY_COORDINATES");
|
||||
const QPointingDevice *dev = QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType(tabletData->tool),
|
||||
QPointingDevice::PointerType(tabletData->pointerType),
|
||||
QPointingDeviceUniqueId::fromNumericId(tabletData->serialId));
|
||||
|
||||
// Valuators' values are relative to the physical size of the current virtual
|
||||
// screen. Therefore we cannot use QScreen/QWindow geometry and should use
|
||||
@ -1597,6 +1600,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
|
||||
tangentialPressure = normalizedValue * 2.0 - 1.0; // Convert 0..1 range to -1..+1 range
|
||||
break;
|
||||
case QInputDevice::DeviceType::Stylus:
|
||||
if (dev->capabilities().testFlag(QInputDevice::Capability::Rotation))
|
||||
rotation = normalizedValue * 360.0 - 180.0; // Convert 0..1 range to -180..+180 degrees
|
||||
break;
|
||||
default: // Other types of styli do not use this valuator
|
||||
@ -1616,11 +1620,10 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
|
||||
local.x(), local.y(), global.x(), global.y(),
|
||||
(int)tabletData->buttons, pressure, xTilt, yTilt, rotation, (int)modifiers);
|
||||
|
||||
QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global,
|
||||
int(tabletData->tool), int(tabletData->pointerType),
|
||||
QWindowSystemInterface::handleTabletEvent(window, ev->time, dev, local, global,
|
||||
tabletData->buttons, pressure,
|
||||
xTilt, yTilt, tangentialPressure,
|
||||
rotation, 0, tabletData->serialId, modifiers);
|
||||
rotation, 0, modifiers);
|
||||
}
|
||||
|
||||
QXcbConnection::TabletData *QXcbConnection::tabletDataForDevice(int id)
|
||||
|
Loading…
Reference in New Issue
Block a user