From 9b72900834a59e07d495fa641526583c2a554840 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 16 Jun 2020 16:43:06 +0200 Subject: Update QTabletEvent device_information manual test - stop using deprecated accessors in QTabletEvent and QMouseEvent - position() and globalPosition() provide high resolution so we don't need to display hi-res global pos separately - keep a pointer to the last-seen QPointingDevice instance rather than copying fields out of it; it will only be deleted if the platform plugin does that (usually only at exit or when it's unplugged) - show seat ID - show platform-specific device ID Change-Id: Ic34e1d1256d6956867992db831c2e66bdda7001e Reviewed-by: Friedemann Kleint --- .../device_information/tabletwidget.cpp | 35 ++++++++++------------ .../qtabletevent/device_information/tabletwidget.h | 15 +++------- 2 files changed, 20 insertions(+), 30 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index 18ea50c854..c4d706d4eb 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -54,18 +54,12 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) case QEvent::TabletRelease: { QTabletEvent *event = static_cast(ev); - mType = event->type(); - mPos = event->pos(); - mGPos = event->globalPos(); - mHiResGlobalPos = event->posF(); - if (event->pointingDevice()) { - mDev = event->pointingDevice()->type(); - mPointerType = event->pointingDevice()->pointerType(); - mCaps = event->pointingDevice()->capabilities(); - } else { + mDev = event->pointingDevice(); + if (!mDev) qWarning() << "missing device in tablet event"; - } - mUnique = event->uniqueId(); + mType = event->type(); + mPos = event->position(); + mGPos = event->globalPosition(); mXT = event->xTilt(); mYT = event->yTilt(); mZ = event->z(); @@ -86,7 +80,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) QMouseEvent *event = static_cast(ev); mType = event->type(); mPos = event->pos(); - mGPos = event->globalPos(); + mGPos = event->globalPosition(); mTimestamp = event->timestamp(); } break; @@ -134,12 +128,16 @@ void TabletWidget::paintEvent(QPaintEvent *) if (mType == QEvent::TabletEnterProximity || mType == QEvent::TabletLeaveProximity || mType == QEvent::TabletMove || mType == QEvent::TabletPress || mType == QEvent::TabletRelease) { - - eventInfo << QString("High res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y())); - - eventInfo << QString("Device type: %1").arg(deviceTypeToString(mDev)); - eventInfo << QString("Pointer type: %1").arg(pointerTypeToString(mPointerType)); - eventInfo << QString("Capabilities: %1").arg(pointerCapabilitiesToString(mCaps)); + if (mDev.isNull()) { + eventInfo << QString("Device info missing"); + } else { + eventInfo << QString("Seat: %1").arg(mDev->seatName()); + eventInfo << QString("Device type: %1").arg(deviceTypeToString(mDev->type())); + eventInfo << QString("Pointer type: %1").arg(pointerTypeToString(mDev->pointerType())); + eventInfo << QString("Capabilities: %1").arg(pointerCapabilitiesToString(mDev->capabilities())); + eventInfo << QString("Unique Id: %1").arg(QString::number(mDev->uniqueId().numericId(), 16)); + eventInfo << QString("System Id: %1").arg(mDev->id()); + } eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); eventInfo << QString("Keyboard modifiers: %1 (0x%2)").arg(modifiersToString(mModifiers)).arg(mModifiers, 0, 16); @@ -150,7 +148,6 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("yTilt: %1").arg(QString::number(mYT)); eventInfo << QString("z: %1").arg(QString::number(mZ)); - eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique, 16)); eventInfo << QString("Total wheel events: %1").arg(QString::number(mWheelEventCount)); } diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index d05b89a74e..b58442ccda 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -51,27 +52,19 @@ protected: QString modifiersToString(Qt::KeyboardModifiers m); private: void resetAttributes() { - mDev = QInputDevice::DeviceType::Unknown; - mPointerType = QPointingDevice::PointerType::Unknown; - mCaps = {}; + mDev.clear(); mType = mXT = mYT = mZ = 0; mPress = mTangential = mRot = 0.0; mPos = mGPos = QPoint(); - mHiResGlobalPos = QPointF(); - mUnique = 0; } + QPointer mDev; int mType; - QPoint mPos, mGPos; - QPointF mHiResGlobalPos; - QInputDevice::DeviceType mDev; - QPointingDevice::PointerType mPointerType; - QPointingDevice::Capabilities mCaps; + QPointF mPos, mGPos; int mXT, mYT, mZ; Qt::MouseButton mButton; Qt::MouseButtons mButtons; Qt::KeyboardModifiers mModifiers; qreal mPress, mTangential, mRot; - qint64 mUnique; bool mMouseToo; ulong mTimestamp; int mWheelEventCount; -- cgit v1.2.3