QWSI: Use floating point number for tablet tilt
On some platforms (like Wayland and X11) we get non-integer values, and the QTabletEvent API also exposes it as qreal. However the QWSI API uses int, resulting in potential loss of information Task-number: QTBUG-8059 Change-Id: I9d2856a053091415c6f9e886fdd87ed71254fdd2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
1da7558bfd
commit
1b05fba9ac
@ -889,7 +889,7 @@ void QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(boo
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
|
||||
const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
@ -903,7 +903,7 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp,
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEvent(QWindow *window, const QPointingDevice *device,
|
||||
const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
@ -914,7 +914,7 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, const QPointingD
|
||||
}
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
@ -925,7 +925,7 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp,
|
||||
}
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEvent(QWindow *window, const QPointF &local, const QPointF &global,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
@ -936,7 +936,7 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, const QPointF &l
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
|
||||
bool inProximity, const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
@ -957,7 +957,7 @@ bool QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(QWindow *windo
|
||||
|
||||
bool QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device,
|
||||
bool inProximity, const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z,
|
||||
Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
|
@ -206,28 +206,28 @@ public:
|
||||
|
||||
static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
|
||||
const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static bool handleTabletEvent(QWindow *window, const QPointingDevice *device,
|
||||
const QPointF &local, const QPointF &global,
|
||||
Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static bool handleTabletEvent(QWindow *window, const QPointF &local, const QPointF &global,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
|
||||
bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
|
||||
Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
|
||||
Qt::MouseButtons buttons = {}, qreal xTilt = 0, qreal yTilt = 0,
|
||||
qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static bool handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device,
|
||||
bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
|
||||
Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
|
||||
Qt::MouseButtons buttons = {}, qreal xTilt = 0 , qreal yTilt = 0,
|
||||
qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
|
||||
|
@ -365,13 +365,13 @@ public:
|
||||
public:
|
||||
// TODO take QPointingDevice* instead of types and IDs
|
||||
static void handleTabletEvent(QWindow *w, const QPointF &local, const QPointF &global,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
|
||||
int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt,
|
||||
qreal tangentialPressure, qreal rotation, int z, qint64 uid,
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
||||
static void setPlatformSynthesizesMouse(bool v);
|
||||
|
||||
TabletEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global,
|
||||
const QPointingDevice *device, Qt::MouseButtons b, qreal pressure, int xTilt, int yTilt, qreal tpressure,
|
||||
const QPointingDevice *device, Qt::MouseButtons b, qreal pressure, qreal xTilt, qreal yTilt, qreal tpressure,
|
||||
qreal rotation, int z, Qt::KeyboardModifiers mods)
|
||||
: PointerEvent(w, time, Tablet, mods, device),
|
||||
buttons(b), local(local), global(global),
|
||||
@ -381,8 +381,8 @@ public:
|
||||
QPointF local;
|
||||
QPointF global;
|
||||
qreal pressure;
|
||||
int xTilt;
|
||||
int yTilt;
|
||||
qreal xTilt;
|
||||
qreal yTilt;
|
||||
qreal tangentialPressure;
|
||||
qreal rotation;
|
||||
int z;
|
||||
|
@ -656,8 +656,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
||||
const qreal tangentialPressure = m_currentDevice->type() == QInputDevice::DeviceType::Airbrush
|
||||
? current.scaleTangentialPressure(packet.pkTangentPressure) : qreal(0);
|
||||
|
||||
int tiltX = 0;
|
||||
int tiltY = 0;
|
||||
qreal tiltX = 0;
|
||||
qreal tiltY = 0;
|
||||
qreal rotation = 0;
|
||||
if (m_tiltSupport) {
|
||||
// Convert from azimuth and altitude to x tilt and y tilt. What
|
||||
@ -672,8 +672,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
|
||||
|
||||
const double radX = std::atan(std::sin(radAzim) / tanAlt);
|
||||
const double radY = std::atan(std::cos(radAzim) / tanAlt);
|
||||
tiltX = int(qRadiansToDegrees(radX));
|
||||
tiltY = int(qRadiansToDegrees(-radY));
|
||||
tiltX = qRadiansToDegrees(radX);
|
||||
tiltY = qRadiansToDegrees(-radY);
|
||||
rotation = 360.0 - (packet.pkOrientation.orTwist / 10.0);
|
||||
if (rotation > 180.0)
|
||||
rotation -= 360.0;
|
||||
|
@ -1598,7 +1598,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
|
||||
QPointF local(fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y));
|
||||
QPointF global(fixed1616ToReal(ev->root_x), fixed1616ToReal(ev->root_y));
|
||||
double pressure = 0, rotation = 0, tangentialPressure = 0;
|
||||
int xTilt = 0, yTilt = 0;
|
||||
qreal 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),
|
||||
@ -1664,7 +1664,7 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
|
||||
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %s %llx type %s seq %d detail %d time %d "
|
||||
"pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf modifiers 0x%x",
|
||||
"pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %4.2lf, %4.2lf rotation %6.2lf modifiers 0x%x",
|
||||
tabletData->deviceId, toolName(tabletData->tool), tabletData->serialId, pointerTypeName(tabletData->pointerType),
|
||||
ev->sequence, ev->detail, ev->time,
|
||||
local.x(), local.y(), global.x(), global.y(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user