summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-05-31 08:38:16 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-16 22:06:56 +0200
commit6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 (patch)
tree61f29061a4cbaf925ef0ab7ba9fafc1db9ee4ef3 /src/plugins/platforms/windows
parent0a2e3ce85ce788b8a07380a458faf4ed3817d0c0 (diff)
Introduce QInputDevice hierarchy; replace QTouchDevice
We have seen during the Qt 5 series that QMouseEvent::source() does not provide enough information: if it is synthesized, it could have come from any device for which mouse events are synthesized, not only from a touchscreen. By providing in every QInputEvent as complete information about the actual source device as possible, we will enable very fine-tuned behavior in the object that handles each event. Further, we would like to support multiple keyboards, pointing devices, and named groups of devices that are known as "seats" in Wayland. In Qt 5, QPA plugins registered each touchscreen as it was discovered. Now we extend this pattern to all input devices. This new requirement can be implemented gradually; for now, if a QTWSI input event is received wtihout a device pointer, a default "core" device will be created on-the-fly, and a warning emitted. In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when multiple devices were in use simultaneously. Now that each event identifies the device it came from, this hack is no longer needed. A stub of the new QPointerEvent is added; it will be developed further in subsequent patches. [ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer to an instance of QInputDevice, or the subclass QPointingDevice in case of mouse, touch and tablet events. Each platform plugin is expected to create the device instances, register them, and provide valid pointers with all input events. If this is not done, warnings are emitted and default devices are created as necessary. When the device has accurate information, it provides the opportunity to fine-tune behavior depending on device type and capabilities: for example if a QMouseEvent is synthesized from a touchscreen, the recipient can see which touchscreen it came from. Each device also has a seatName to distinguish users on multi-user windowing systems. Touchpoint IDs are no longer unique on their own, but the combination of ID and device is. Fixes: QTBUG-46412 Fixes: QTBUG-72167 Task-number: QTBUG-69433 Task-number: QTBUG-52430 Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp16
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h8
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.cpp70
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.h10
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp57
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h6
9 files changed, 98 insertions, 85 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 9b7c89fa05..f17fc1629b 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -70,7 +70,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qopenglcontext.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtCore/qset.h>
#include <QtCore/qhash.h>
@@ -348,15 +348,15 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
if (d->m_systemInfo & QWindowsContext::SI_SupportsTouch)
return true;
- QTouchDevice *touchDevice = (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ?
+ QPointingDevice *touchDevice = (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ?
d->m_pointerHandler.ensureTouchDevice() : d->m_mouseHandler.ensureTouchDevice();
if (!touchDevice)
return false;
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
- touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
+ touchDevice->setCapabilities(touchDevice->capabilities() | QInputDevice::Capability::MouseEmulation);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
+ QWindowSystemInterface::registerInputDevice(touchDevice);
d->m_systemInfo |= QWindowsContext::SI_SupportsTouch;
@@ -1631,7 +1631,7 @@ void QWindowsContext::setAsyncExpose(bool value)
d->m_asyncExpose = value;
}
-QTouchDevice *QWindowsContext::touchDevice() const
+QPointingDevice *QWindowsContext::touchDevice() const
{
return (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ?
d->m_pointerHandler.touchDevice() : d->m_mouseHandler.touchDevice();
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 67d23b3c0c..1e1edba000 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -80,7 +80,7 @@ struct QWindowCreationContext;
struct QWindowsContextPrivate;
class QPoint;
class QKeyEvent;
-class QTouchDevice;
+class QPointingDevice;
struct QWindowsUser32DLL
{
@@ -265,7 +265,7 @@ public:
static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue);
- QTouchDevice *touchDevice() const;
+ QPointingDevice *touchDevice() const;
static bool filterNativeEvent(MSG *msg, LRESULT *result);
static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 303bf4e5a2..96abfe5b01 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -73,7 +73,7 @@
#if QT_CONFIG(sessionmanager)
# include "qwindowssessionmanager.h"
#endif
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qpa/qplatforminputcontextfactory_p.h>
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 1b2d831268..4fd6e4131e 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -47,7 +47,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qscreen.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/qwindow.h>
#include <QtGui/qcursor.h>
@@ -117,7 +117,7 @@ static inline void compressMouseMove(MSG *msg)
}
}
-static inline QTouchDevice *createTouchDevice()
+static inline QPointingDevice *createTouchDevice()
{
const int digitizers = GetSystemMetrics(SM_DIGITIZER);
if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH)))
@@ -127,12 +127,12 @@ static inline QTouchDevice *createTouchDevice()
qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY)
<< "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase
<< "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints;
- auto *result = new QTouchDevice;
+ auto *result = new QPointingDevice;
result->setType(digitizers & NID_INTEGRATED_TOUCH
- ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad);
- QTouchDevice::Capabilities capabilities = QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition;
- if (result->type() == QTouchDevice::TouchPad)
- capabilities |= QTouchDevice::MouseEmulation;
+ ? QInputDevice::DeviceType::TouchScreen : QInputDevice::DeviceType::TouchPad);
+ QPointingDevice::Capabilities capabilities = QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::NormalizedPosition;
+ if (result->type() == QInputDevice::DeviceType::TouchPad)
+ capabilities.setFlag(QInputDevice::Capability::MouseEmulation);
result->setCapabilities(capabilities);
result->setMaximumTouchPoints(maxTouchPoints);
return result;
@@ -149,7 +149,7 @@ static inline QTouchDevice *createTouchDevice()
QWindowsMouseHandler::QWindowsMouseHandler() = default;
-QTouchDevice *QWindowsMouseHandler::ensureTouchDevice()
+QPointingDevice *QWindowsMouseHandler::ensureTouchDevice()
{
if (!m_touchDevice)
m_touchDevice = createTouchDevice();
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index 1d3d1f4761..764733e3ad 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
class QWindow;
-class QTouchDevice;
+class QPointingDevice;
class QWindowsMouseHandler
{
@@ -58,8 +58,8 @@ class QWindowsMouseHandler
public:
QWindowsMouseHandler();
- QTouchDevice *touchDevice() const { return m_touchDevice; }
- QTouchDevice *ensureTouchDevice();
+ QPointingDevice *touchDevice() const { return m_touchDevice; }
+ QPointingDevice *ensureTouchDevice();
bool translateMouseEvent(QWindow *widget, HWND hwnd,
QtWindows::WindowsEventType t, MSG msg,
@@ -90,7 +90,7 @@ private:
QPointer<QWindow> m_trackedWindow;
QHash<DWORD, int> m_touchInputIDToTouchPointID;
QHash<int, QPointF> m_lastTouchPositions;
- QTouchDevice *m_touchDevice = nullptr;
+ QPointingDevice *m_touchDevice = nullptr;
bool m_leftButtonDown = false;
QWindow *m_previousCaptureWindow = nullptr;
QEvent::Type m_lastEventType = QEvent::None;
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index fba24d8696..7c6ca0a61e 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -53,7 +53,7 @@
#include <QtGui/qguiapplication.h>
#include <QtGui/qscreen.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/qwindow.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtCore/qvarlengtharray.h>
@@ -75,6 +75,13 @@ enum {
QT_PT_TOUCHPAD = 5, // MinGW is missing PT_TOUCHPAD
};
+qint64 QWindowsPointerHandler::m_nextInputDeviceId = 1;
+
+QWindowsPointerHandler::~QWindowsPointerHandler()
+{
+ delete m_touchDevice;
+}
+
bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result)
{
*result = 0;
@@ -310,31 +317,30 @@ static bool isValidWheelReceiver(QWindow *candidate)
return false;
}
-static QTouchDevice *createTouchDevice()
-{
- const int digitizers = GetSystemMetrics(SM_DIGITIZER);
- if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH)))
- return nullptr;
- const int tabletPc = GetSystemMetrics(SM_TABLETPC);
- const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES);
- qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY)
- << "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase
- << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints;
- auto *result = new QTouchDevice;
- result->setType(digitizers & NID_INTEGRATED_TOUCH
- ? QTouchDevice::TouchScreen : QTouchDevice::TouchPad);
- QTouchDevice::Capabilities capabilities = QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition;
- if (result->type() == QTouchDevice::TouchPad)
- capabilities |= QTouchDevice::MouseEmulation;
- result->setCapabilities(capabilities);
- result->setMaximumTouchPoints(maxTouchPoints);
- return result;
-}
-
-QTouchDevice *QWindowsPointerHandler::ensureTouchDevice()
+QPointingDevice *QWindowsPointerHandler::ensureTouchDevice()
{
- if (!m_touchDevice)
- m_touchDevice = createTouchDevice();
+ if (!m_touchDevice) {
+ const int digitizers = GetSystemMetrics(SM_DIGITIZER);
+ if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH)))
+ return nullptr;
+ const int tabletPc = GetSystemMetrics(SM_TABLETPC);
+ const int maxTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES);
+ const bool touchScreen = digitizers & NID_INTEGRATED_TOUCH;
+ QPointingDevice::Capabilities capabilities = QPointingDevice::Capability::Position;
+ if (!touchScreen) {
+ capabilities.setFlag(QInputDevice::Capability::MouseEmulation);
+ capabilities.setFlag(QInputDevice::Capability::Scroll);
+ }
+ qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY)
+ << "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase
+ << "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints << "Capabilities:" << capabilities;
+ // TODO: use system-provided name and device ID rather than empty-string and m_nextInputDeviceId
+ m_touchDevice = new QPointingDevice(QString(), m_nextInputDeviceId++,
+ (touchScreen ? QInputDevice::DeviceType::TouchScreen : QInputDevice::DeviceType::TouchPad),
+ QPointingDevice::PointerType::Finger, capabilities, maxTouchPoints,
+ // TODO: precise button count (detect whether the touchpad can emulate 3 or more buttons)
+ (touchScreen ? 1 : 3));
+ }
return m_touchDevice;
}
@@ -577,8 +583,8 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
<< " message=" << Qt::hex << msg.message
<< " flags=" << Qt::hex << penInfo->pointerInfo.pointerFlags;
- const QTabletEvent::TabletDevice device = QTabletEvent::Stylus;
- QTabletEvent::PointerType type;
+ const QInputDevice::DeviceType device = QInputDevice::DeviceType::Stylus;
+ QPointingDevice::PointerType type;
// Since it may be the middle button, so if the checks fail then it should
// be set to Middle if it was used.
Qt::MouseButtons mouseButtons = queryMouseButtons();
@@ -588,16 +594,16 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
mouseButtons = Qt::LeftButton;
if (penInfo->penFlags & (PEN_FLAG_ERASER | PEN_FLAG_INVERTED)) {
- type = QTabletEvent::Eraser;
+ type = QPointingDevice::PointerType::Eraser;
} else {
- type = QTabletEvent::Pen;
+ type = QPointingDevice::PointerType::Pen;
if (pointerInContact && penInfo->penFlags & PEN_FLAG_BARREL)
mouseButtons = Qt::RightButton; // Either left or right, not both
}
switch (msg.message) {
case WM_POINTERENTER: {
- QWindowSystemInterface::handleTabletEnterProximityEvent(device, type, sourceDevice);
+ QWindowSystemInterface::handleTabletEnterProximityEvent(int(device), int(type), sourceDevice);
m_windowUnderPointer = window;
// The local coordinates may fall outside the window.
// Wait until the next update to send the enter event.
@@ -610,7 +616,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
m_windowUnderPointer = nullptr;
m_currentWindow = nullptr;
}
- QWindowSystemInterface::handleTabletLeaveProximityEvent(device, type, sourceDevice);
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(int(device), int(type), sourceDevice);
break;
case WM_POINTERDOWN:
case WM_POINTERUP:
@@ -635,7 +641,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
}
const Qt::KeyboardModifiers keyModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
- QWindowSystemInterface::handleTabletEvent(target, localPos, hiResGlobalPos, device, type, mouseButtons,
+ QWindowSystemInterface::handleTabletEvent(target, localPos, hiResGlobalPos, int(device), int(type), mouseButtons,
pressure, xTilt, yTilt, tangentialPressure, rotation, z,
sourceDevice, keyModifiers);
return false; // Allow mouse messages to be generated.
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.h b/src/plugins/platforms/windows/qwindowspointerhandler.h
index 8874db27e3..d232941ba5 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.h
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.h
@@ -51,17 +51,18 @@
QT_BEGIN_NAMESPACE
class QWindow;
-class QTouchDevice;
+class QPointingDevice;
class QWindowsPointerHandler
{
Q_DISABLE_COPY_MOVE(QWindowsPointerHandler)
public:
QWindowsPointerHandler() = default;
+ ~QWindowsPointerHandler();
bool translatePointerEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result);
bool translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result);
- QTouchDevice *touchDevice() const { return m_touchDevice; }
- QTouchDevice *ensureTouchDevice();
+ QPointingDevice *touchDevice() const { return m_touchDevice; }
+ QPointingDevice *ensureTouchDevice();
QWindow *windowUnderMouse() const { return m_windowUnderPointer.data(); }
void clearWindowUnderMouse() { m_windowUnderPointer = nullptr; }
void clearEvents();
@@ -73,7 +74,7 @@ private:
void handleCaptureRelease(QWindow *window, QWindow *currentWindowUnderPointer, HWND hwnd, QEvent::Type eventType, Qt::MouseButtons mouseButtons);
void handleEnterLeave(QWindow *window, QWindow *currentWindowUnderPointer, QPoint globalPos);
- QTouchDevice *m_touchDevice = nullptr;
+ QPointingDevice *m_touchDevice = nullptr;
QHash<int, QPointF> m_lastTouchPositions;
QHash<DWORD, int> m_touchInputIDToTouchPointID;
QPointer<QWindow> m_windowUnderPointer;
@@ -83,6 +84,7 @@ private:
QEvent::Type m_lastEventType = QEvent::None;
Qt::MouseButton m_lastEventButton = Qt::NoButton;
DWORD m_pointerType = 0;
+ static qint64 m_nextInputDeviceId; // workaround until we know how to get system device IDs
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 287ba931d9..f2c82f3247 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -326,42 +326,42 @@ static inline int indexOfDevice(const QVector<QWindowsTabletDeviceData> &devices
return -1;
}
-static inline QTabletEvent::TabletDevice deviceType(const UINT cursorType)
+static inline QInputDevice::DeviceType deviceType(const UINT cursorType)
{
if (((cursorType & 0x0006) == 0x0002) && ((cursorType & CursorTypeBitMask) != 0x0902))
- return QTabletEvent::Stylus;
+ return QInputDevice::DeviceType::Stylus;
if (cursorType == 0x4020) // Surface Pro 2 tablet device
- return QTabletEvent::Stylus;
+ return QInputDevice::DeviceType::Stylus;
switch (cursorType & CursorTypeBitMask) {
case 0x0802:
- return QTabletEvent::Stylus;
+ return QInputDevice::DeviceType::Stylus;
case 0x0902:
- return QTabletEvent::Airbrush;
+ return QInputDevice::DeviceType::Airbrush;
case 0x0004:
- return QTabletEvent::FourDMouse;
+ return QInputDevice::DeviceType::Mouse;
case 0x0006:
- return QTabletEvent::Puck;
+ return QInputDevice::DeviceType::Puck;
case 0x0804:
- return QTabletEvent::RotationStylus;
+ return QInputDevice::DeviceType::Stylus;
default:
break;
}
- return QTabletEvent::NoDevice;
+ return QInputDevice::DeviceType::Unknown;
}
-static inline QTabletEvent::PointerType pointerType(unsigned currentCursor)
+static inline QPointingDevice::PointerType pointerType(unsigned currentCursor)
{
switch (currentCursor % 3) { // %3 for dual track
case 0:
- return QTabletEvent::Cursor;
+ return QPointingDevice::PointerType::Cursor;
case 1:
- return QTabletEvent::Pen;
+ return QPointingDevice::PointerType::Pen;
case 2:
- return QTabletEvent::Eraser;
+ return QPointingDevice::PointerType::Eraser;
default:
break;
}
- return QTabletEvent::UnknownPointer;
+ return QPointingDevice::PointerType::Unknown;
}
QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(qint64 uniqueId, UINT cursorType) const
@@ -389,6 +389,7 @@ QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(qint64 uniqueId, UINT
result.maxY = int(defaultLc.lcInExtY) - int(defaultLc.lcInOrgY);
result.maxZ = int(defaultLc.lcInExtZ) - int(defaultLc.lcInOrgZ);
result.currentDevice = deviceType(cursorType);
+ result.zCapability = (cursorType == 0x0004);
return result;
}
@@ -404,12 +405,12 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
m_state = PenUp;
if (totalPacks > 0) {
QWindowSystemInterface::handleTabletLeaveProximityEvent(proximityBuffer[0].pkTime,
- m_devices.at(m_currentDevice).currentDevice,
- m_devices.at(m_currentDevice).currentPointerType,
+ int(m_devices.at(m_currentDevice).currentDevice),
+ int(m_devices.at(m_currentDevice).currentPointerType),
m_devices.at(m_currentDevice).uniqueId);
} else {
- QWindowSystemInterface::handleTabletLeaveProximityEvent(m_devices.at(m_currentDevice).currentDevice,
- m_devices.at(m_currentDevice).currentPointerType,
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(int(m_devices.at(m_currentDevice).currentDevice),
+ int(m_devices.at(m_currentDevice).currentPointerType),
m_devices.at(m_currentDevice).uniqueId);
}
@@ -458,9 +459,11 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
m_state = PenProximity;
qCDebug(lcQpaTablet) << "enter proximity for device #"
<< m_currentDevice << m_devices.at(m_currentDevice);
+ // TODO use the version taking a QPointingDevice, and own those instances; replace QWindowsTabletDeviceData
+ // TODO QWindowSystemInterface::registerInputDevice() as early as possible, and before sending any events from it
QWindowSystemInterface::handleTabletEnterProximityEvent(proximityBuffer[0].pkTime,
- m_devices.at(m_currentDevice).currentDevice,
- m_devices.at(m_currentDevice).currentPointerType,
+ int(m_devices.at(m_currentDevice).currentDevice),
+ int(m_devices.at(m_currentDevice).currentPointerType),
m_devices.at(m_currentDevice).uniqueId);
return true;
}
@@ -518,8 +521,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
if (!packetCount || m_currentDevice < 0)
return false;
- const int currentDevice = m_devices.at(m_currentDevice).currentDevice;
- const int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
+ const auto currentDevice = m_devices.at(m_currentDevice).currentDevice;
+ const auto currentPointer = m_devices.at(m_currentDevice).currentPointerType;
const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId;
// The tablet can be used in 2 different modes (reflected in enum Mode),
@@ -549,7 +552,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
for (int i = 0; i < packetCount ; ++i) {
const PACKET &packet = localPacketBuf[i];
- const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0;
+ const int z = m_devices.at(m_currentDevice).zCapability ? int(packet.pkZ) : 0;
QPointF globalPosF =
m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
@@ -578,10 +581,10 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
Q_ASSERT(platformWindow);
const QPoint localPos = platformWindow->mapFromGlobal(globalPos);
- const qreal pressureNew = packet.pkButtons && (currentPointer == QTabletEvent::Pen || currentPointer == QTabletEvent::Eraser) ?
+ const qreal pressureNew = packet.pkButtons && (currentPointer == QPointingDevice::PointerType::Pen || currentPointer == QPointingDevice::PointerType::Eraser) ?
m_devices.at(m_currentDevice).scalePressure(packet.pkNormalPressure) :
qreal(0);
- const qreal tangentialPressure = currentDevice == QTabletEvent::Airbrush ?
+ const qreal tangentialPressure = currentDevice == QInputDevice::DeviceType::Airbrush ?
m_devices.at(m_currentDevice).scaleTangentialPressure(packet.pkTangentPressure) :
qreal(0);
@@ -621,7 +624,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
convertTabletButtons(packet.pkButtons, m_devices.at(m_currentDevice));
QWindowSystemInterface::handleTabletEvent(target, packet.pkTime, QPointF(localPos), globalPosF,
- currentDevice, currentPointer,
+ int(currentDevice), int(currentPointer),
buttons,
pressureNew, tiltX, tiltY,
tangentialPressure, rotation, z,
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 6bcf3357a5..b50b1875dc 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -42,6 +42,7 @@
#include "qtwindowsglobal.h"
#include <QtGui/qtguiglobal.h>
+#include <QtGui/qpointingdevice.h>
#include <QtCore/qvector.h>
#include <QtCore/qpoint.h>
@@ -99,8 +100,9 @@ struct QWindowsTabletDeviceData
int minZ = 0;
int maxZ = 0;
qint64 uniqueId = 0;
- int currentDevice = 0;
- int currentPointerType = 0;
+ QInputDevice::DeviceType currentDevice = QInputDevice::DeviceType::Unknown;
+ QPointingDevice::PointerType currentPointerType = QPointingDevice::PointerType::Unknown;
+ bool zCapability = false;
QHash<quint8, quint8> buttonsMap;
};