summaryrefslogtreecommitdiffstats
path: root/src/plugins
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
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')
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp21
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler_p.h4
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp19
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp15
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.h6
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac.mm21
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac_p.h6
-rw-r--r--src/plugins/platforms/cocoa/qnsview_gestures.mm12
-rw-r--r--src/plugins/platforms/cocoa/qnsview_tablet.mm40
-rw-r--r--src/plugins/platforms/cocoa/qnsview_touch.mm8
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h4
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm14
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm2
-rw-r--r--src/plugins/platforms/ios/quiview.mm20
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp9
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.h2
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp8
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.h4
-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
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h13
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp404
29 files changed, 494 insertions, 321 deletions
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 6ad4597b19..1ef50915d8 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -47,7 +47,7 @@
#include <qpa/qwindowsysteminterface.h>
-#include <QTouchDevice>
+#include <QPointingDevice>
#include <QWindow>
#include <QGuiApplication>
@@ -68,7 +68,6 @@ Q_LOGGING_CATEGORY(lcTuioSet, "qt.qpa.tuio.set")
static bool forceDelivery = qEnvironmentVariableIsSet("QT_TUIOTOUCH_DELIVER_WITHOUT_FOCUS");
QTuioHandler::QTuioHandler(const QString &specification)
- : m_device(new QTouchDevice) // not leaked, QTouchDevice cleans up registered devices itself
{
QStringList args = specification.split(':');
int portNumber = 3333;
@@ -111,13 +110,17 @@ QTuioHandler::QTuioHandler(const QString &specification)
if (inverty)
m_transform *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5);
- m_device->setName("TUIO"); // TODO: multiple based on SOURCE?
- m_device->setType(QTouchDevice::TouchScreen);
- m_device->setCapabilities(QTouchDevice::Position |
- QTouchDevice::Area |
- QTouchDevice::Velocity |
- QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(m_device);
+ // not leaked, QPointingDevice cleans up registered devices itself
+ // TODO register each device based on SOURCE, not just an all-purpose generic touchscreen
+ // TODO define seats when multiple connections occur
+ m_device = new QPointingDevice(QLatin1String("TUIO"), 1, QInputDevice::DeviceType::TouchScreen,
+ QPointingDevice::PointerType::Finger,
+ QInputDevice::Capability::Position |
+ QInputDevice::Capability::Area |
+ QInputDevice::Capability::Velocity |
+ QInputDevice::Capability::NormalizedPosition,
+ 16, 0);
+ QWindowSystemInterface::registerInputDevice(m_device);
if (!m_socket.bind(QHostAddress::Any, portNumber)) {
qCWarning(lcTuioHandler) << "Failed to bind TUIO socket: " << m_socket.errorString();
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler_p.h b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
index eb68baa915..09de1d8536 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler_p.h
+++ b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
@@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
-class QTouchDevice;
+class QPointingDevice;
class QOscMessage;
class QTuioCursor;
class QTuioToken;
@@ -80,7 +80,7 @@ private:
QWindowSystemInterface::TouchPoint cursorToTouchPoint(const QTuioCursor &tc, QWindow *win);
QWindowSystemInterface::TouchPoint tokenToTouchPoint(const QTuioToken &tc, QWindow *win);
- QTouchDevice *m_device;
+ QPointingDevice *m_device = nullptr;
QUdpSocket m_socket;
QMap<int, QTuioCursor> m_activeCursors;
QVector<QTuioCursor> m_deadCursors;
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 68e8da03a4..9906bdffd3 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -45,7 +45,6 @@
#include "qandroidplatformintegration.h"
#include <qpa/qwindowsysteminterface.h>
-#include <QTouchDevice>
#include <QTouchEvent>
#include <QPointer>
@@ -276,15 +275,15 @@ namespace QtAndroidInput
if (!platformIntegration)
return;
- QTouchDevice *touchDevice = platformIntegration->touchDevice();
+ QPointingDevice *touchDevice = platformIntegration->touchDevice();
if (touchDevice == 0) {
- touchDevice = new QTouchDevice;
- touchDevice->setType(QTouchDevice::TouchScreen);
- touchDevice->setCapabilities(QTouchDevice::Position
- | QTouchDevice::Area
- | QTouchDevice::Pressure
- | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
+ touchDevice = new QPointingDevice; // TODO fill out the constructor args
+ touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
+ touchDevice->setCapabilities(QPointingDevice::Capability::Position
+ | QPointingDevice::Capability::Area
+ | QPointingDevice::Capability::Pressure
+ | QPointingDevice::Capability::NormalizedPosition);
+ QWindowSystemInterface::registerInputDevice(touchDevice);
platformIntegration->setTouchDevice(touchDevice);
}
@@ -344,7 +343,7 @@ namespace QtAndroidInput
#endif
QWindowSystemInterface::handleTabletEvent(tlw, ulong(time),
- localPos, globalPosF, QTabletEvent::Stylus, pointerType,
+ localPos, globalPosF, int(QInputDevice::DeviceType::Stylus), pointerType,
buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier);
#endif // QT_CONFIG(tabletevent)
}
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 50ab772d5a..d059096dbc 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -48,7 +48,6 @@
#endif
#include <QOffscreenSurface>
#include <QThread>
-#include <QTouchDevice>
#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <qpa/qwindowsysteminterface.h>
@@ -208,12 +207,12 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
if (touchScreen == QJNIObjectPrivate::getStaticField<jint>("android/content/res/Configuration", "TOUCHSCREEN_FINGER")
|| touchScreen == QJNIObjectPrivate::getStaticField<jint>("android/content/res/Configuration", "TOUCHSCREEN_STYLUS"))
{
- m_touchDevice = new QTouchDevice;
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- m_touchDevice->setCapabilities(QTouchDevice::Position
- | QTouchDevice::Area
- | QTouchDevice::Pressure
- | QTouchDevice::NormalizedPosition);
+ m_touchDevice = new QPointingDevice;
+ m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
+ m_touchDevice->setCapabilities(QPointingDevice::Capability::Position
+ | QPointingDevice::Capability::Area
+ | QPointingDevice::Capability::Pressure
+ | QPointingDevice::Capability::NormalizedPosition);
QJNIObjectPrivate pm = javaActivity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;");
Q_ASSERT(pm.isValid());
@@ -227,7 +226,7 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
QJNIObjectPrivate::getStaticObjectField("android/content/pm/PackageManager", "FEATURE_TOUCHSCREEN_MULTITOUCH", "Ljava/lang/String;").object())) {
m_touchDevice->setMaximumTouchPoints(2);
}
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+ QWindowSystemInterface::registerInputDevice(m_touchDevice);
}
auto contentResolver = javaActivity.callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h
index fab2083338..e6a36240d0 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/qandroidplatformintegration.h
@@ -128,8 +128,8 @@ public:
static void setScreenOrientation(Qt::ScreenOrientation currentOrientation,
Qt::ScreenOrientation nativeOrientation);
- QTouchDevice *touchDevice() const { return m_touchDevice; }
- void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; }
+ QPointingDevice *touchDevice() const { return m_touchDevice; }
+ void setTouchDevice(QPointingDevice *touchDevice) { m_touchDevice = touchDevice; }
void flushPendingUpdates();
@@ -139,7 +139,7 @@ public:
private:
EGLDisplay m_eglDisplay;
- QTouchDevice *m_touchDevice;
+ QPointingDevice *m_touchDevice;
QAndroidPlatformScreen *m_primaryScreen;
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
index 3f7402aeed..7bbbb486e5 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
@@ -42,14 +42,14 @@
#include "qmultitouch_mac_p.h"
#include "qcocoahelpers.h"
#include "qcocoascreen.h"
-#include <private/qtouchdevice_p.h>
+#include <private/qpointingdevice_p.h>
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcInputDevices, "qt.qpa.input.devices")
QHash<qint64, QCocoaTouch*> QCocoaTouch::_currentTouches;
-QHash<quint64, QTouchDevice*> QCocoaTouch::_touchDevices;
+QHash<quint64, QPointingDevice*> QCocoaTouch::_touchDevices;
QPointF QCocoaTouch::_screenReferencePos;
QPointF QCocoaTouch::_trackpadReferencePos;
int QCocoaTouch::_idAssignmentCount = 0;
@@ -219,17 +219,18 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch)
return touchPoints.values();
}
-QTouchDevice *QCocoaTouch::getTouchDevice(QTouchDevice::DeviceType type, quint64 id)
+QPointingDevice *QCocoaTouch::getTouchDevice(QInputDevice::DeviceType type, quint64 id)
{
- QTouchDevice *ret = _touchDevices.value(id);
+ QPointingDevice *ret = _touchDevices.value(id);
if (!ret) {
- ret = new QTouchDevice;
- ret->setType(type);
- ret->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation);
- QWindowSystemInterface::registerTouchDevice(ret);
+ ret = new QPointingDevice(type == QInputDevice::DeviceType::TouchScreen ? QLatin1String("touchscreen") : QLatin1String("trackpad"),
+ id, type, QPointingDevice::PointerType::Finger,
+ QInputDevice::Capability::Position |
+ QInputDevice::Capability::NormalizedPosition |
+ QInputDevice::Capability::MouseEmulation,
+ 10, 0);
+ QWindowSystemInterface::registerInputDevice(ret);
_touchDevices.insert(id, ret);
- qCDebug(lcInputDevices) << "touch device" << id << "of type" << type
- << "registered as Qt device" << QTouchDevicePrivate::get(ret)->id;
}
return ret;
}
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
index f29367ccff..875a7d365e 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
@@ -55,7 +55,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qhash.h>
#include <QtCore>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtCore/private/qcore_mac_p.h>
@@ -69,10 +69,10 @@ class QCocoaTouch
public:
static QList<QWindowSystemInterface::TouchPoint> getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch);
static void setMouseInDraggingState(bool inDraggingState);
- static QTouchDevice *getTouchDevice(QTouchDevice::DeviceType type, quint64 id);
+ static QPointingDevice *getTouchDevice(QInputDevice::DeviceType type, quint64 id);
private:
- static QHash<quint64, QTouchDevice*> _touchDevices;
+ static QHash<quint64, QPointingDevice*> _touchDevices;
static QHash<qint64, QCocoaTouch*> _currentTouches;
static QPointF _screenReferencePos;
static QPointF _trackpadReferencePos;
diff --git a/src/plugins/platforms/cocoa/qnsview_gestures.mm b/src/plugins/platforms/cocoa/qnsview_gestures.mm
index a80261fd6a..0444c0d385 100644
--- a/src/plugins/platforms/cocoa/qnsview_gestures.mm
+++ b/src/plugins/platforms/cocoa/qnsview_gestures.mm
@@ -75,7 +75,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::ZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::ZoomNativeGesture,
[event magnification], windowPoint, screenPoint);
}
@@ -90,7 +90,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SmartZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::SmartZoomNativeGesture,
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
zoomIn = !zoomIn;
}
@@ -107,7 +107,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::RotateNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::RotateNativeGesture,
-[event rotation], windowPoint, screenPoint);
}
@@ -132,7 +132,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
else if ([event deltaY] == -1)
angle = 270.0f;
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SwipeNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::SwipeNativeGesture,
angle, windowPoint, screenPoint);
}
@@ -146,7 +146,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << Qt::hex << [event deviceID];
- QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::BeginNativeGesture,
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::BeginNativeGesture,
windowPoint, screenPoint);
}
@@ -160,7 +160,7 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::EndNativeGesture,
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), timestamp, Qt::EndNativeGesture,
windowPoint, screenPoint);
}
diff --git a/src/plugins/platforms/cocoa/qnsview_tablet.mm b/src/plugins/platforms/cocoa/qnsview_tablet.mm
index ba1fa55892..062e147daf 100644
--- a/src/plugins/platforms/cocoa/qnsview_tablet.mm
+++ b/src/plugins/platforms/cocoa/qnsview_tablet.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 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.
@@ -41,12 +41,14 @@
#ifndef QT_NO_TABLETEVENT
+#include "qpointingdevice.h"
+
Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
struct QCocoaTabletDeviceData
{
- QTabletEvent::TabletDevice device;
- QTabletEvent::PointerType pointerType;
+ QInputDevice::DeviceType device;
+ QPointingDevice::PointerType pointerType;
uint capabilityMask;
qint64 uid;
};
@@ -116,7 +118,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
static_cast<uint>(buttons), pressure, xTilt, yTilt, rotation);
QWindowSystemInterface::handleTabletEvent(m_platformWindow->window(), timestamp, windowPoint, screenPoint,
- deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt,
+ int(deviceData.device), int(deviceData.pointerType), buttons, pressure, xTilt, yTilt,
tangentialPressure, rotation, z, deviceData.uid,
keyboardModifiers);
return true;
@@ -130,7 +132,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash)
[self handleTabletEvent: theEvent];
}
-static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
+static QInputDevice::DeviceType wacomTabletDevice(NSEvent *theEvent)
{
qint64 uid = [theEvent uniqueID];
uint bits = [theEvent vendorPointingDeviceType];
@@ -141,30 +143,30 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
bits = uid >> 32;
}
- QTabletEvent::TabletDevice device;
+ QInputDevice::DeviceType device;
// Defined in the "EN0056-NxtGenImpGuideX"
// on Wacom's Developer Website (www.wacomeng.com)
if (((bits & 0x0006) == 0x0002) && ((bits & 0x0F06) != 0x0902)) {
- device = QTabletEvent::Stylus;
+ device = QInputDevice::DeviceType::Stylus;
} else {
switch (bits & 0x0F06) {
case 0x0802:
- device = QTabletEvent::Stylus;
+ device = QInputDevice::DeviceType::Stylus;
break;
case 0x0902:
- device = QTabletEvent::Airbrush;
+ device = QInputDevice::DeviceType::Airbrush;
break;
case 0x0004:
- device = QTabletEvent::FourDMouse;
+ device = QInputDevice::DeviceType::Mouse; // TODO set capabilities
break;
case 0x0006:
- device = QTabletEvent::Puck;
+ device = QInputDevice::DeviceType::Puck;
break;
case 0x0804:
- device = QTabletEvent::RotationStylus;
+ device = QInputDevice::DeviceType::Stylus; // TODO set capability rotation
break;
default:
- device = QTabletEvent::NoDevice;
+ device = QInputDevice::DeviceType::Unknown;
}
}
return device;
@@ -184,16 +186,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
switch ([theEvent pointingDeviceType]) {
case NSPointingDeviceTypeUnknown:
default:
- deviceData.pointerType = QTabletEvent::UnknownPointer;
+ deviceData.pointerType = QPointingDevice::PointerType::Unknown;
break;
case NSPointingDeviceTypePen:
- deviceData.pointerType = QTabletEvent::Pen;
+ deviceData.pointerType = QPointingDevice::PointerType::Pen;
break;
case NSPointingDeviceTypeCursor:
- deviceData.pointerType = QTabletEvent::Cursor;
+ deviceData.pointerType = QPointingDevice::PointerType::Cursor;
break;
case NSPointingDeviceTypeEraser:
- deviceData.pointerType = QTabletEvent::Eraser;
+ deviceData.pointerType = QPointingDevice::PointerType::Eraser;
break;
}
@@ -213,9 +215,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
deviceId, deviceData.device, deviceData.pointerType, deviceData.uid);
if (entering) {
- QWindowSystemInterface::handleTabletEnterProximityEvent(timestamp, deviceData.device, deviceData.pointerType, deviceData.uid);
+ QWindowSystemInterface::handleTabletEnterProximityEvent(timestamp, int(deviceData.device), int(deviceData.pointerType), deviceData.uid);
} else {
- QWindowSystemInterface::handleTabletLeaveProximityEvent(timestamp, deviceData.device, deviceData.pointerType, deviceData.uid);
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(timestamp, int(deviceData.device), int(deviceData.pointerType), deviceData.uid);
}
}
@end
diff --git a/src/plugins/platforms/cocoa/qnsview_touch.mm b/src/plugins/platforms/cocoa/qnsview_touch.mm
index 8dfae27c63..7f7847849d 100644
--- a/src/plugins/platforms/cocoa/qnsview_touch.mm
+++ b/src/plugins/platforms/cocoa/qnsview_touch.mm
@@ -61,7 +61,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << Qt::hex << [event deviceID];
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), points);
}
- (void)touchesMovedWithEvent:(NSEvent *)event
@@ -72,7 +72,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), points);
}
- (void)touchesEndedWithEvent:(NSEvent *)event
@@ -83,7 +83,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), points);
}
- (void)touchesCancelledWithEvent:(NSEvent *)event
@@ -94,7 +94,7 @@ Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << Qt::hex << [event deviceID];
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]), points);
}
@end
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h
index eeb44b54d3..f1e0fe0641 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -87,7 +87,7 @@ public:
QAbstractEventDispatcher *createEventDispatcher() const override;
QPlatformNativeInterface *nativeInterface() const override;
- QTouchDevice *touchDevice();
+ QPointingDevice *touchDevice();
#ifndef QT_NO_ACCESSIBILITY
QPlatformAccessibility *accessibility() const override;
#endif
@@ -110,7 +110,7 @@ private:
QPlatformClipboard *m_clipboard;
#endif
QPlatformInputContext *m_inputContext;
- QTouchDevice *m_touchDevice;
+ QPointingDevice *m_touchDevice;
QIOSServices *m_platformServices;
mutable QPlatformAccessibility *m_accessibility;
QFactoryLoader *m_optionalPlugins;
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 7352e68562..962456965a 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -53,7 +53,7 @@
#include "qiosservices.h"
#include "qiosoptionalplugininterface.h"
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qoffscreensurface.h>
@@ -117,13 +117,13 @@ void QIOSIntegration::initialize()
// Depends on a primary screen being present
m_inputContext = new QIOSInputContext;
- m_touchDevice = new QTouchDevice;
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition;
+ m_touchDevice = new QPointingDevice;
+ m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
+ QPointingDevice::Capabilities touchCapabilities = QPointingDevice::Capability::Position | QPointingDevice::Capability::NormalizedPosition;
if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
- touchCapabilities |= QTouchDevice::Pressure;
+ touchCapabilities |= QPointingDevice::Capability::Pressure;
m_touchDevice->setCapabilities(touchCapabilities);
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+ QWindowSystemInterface::registerInputDevice(m_touchDevice);
#if QT_CONFIG(tabletevent)
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
#endif
@@ -280,7 +280,7 @@ QPlatformTheme *QIOSIntegration::createPlatformTheme(const QString &name) const
return QPlatformIntegration::createPlatformTheme(name);
}
-QTouchDevice *QIOSIntegration::touchDevice()
+QPointingDevice *QIOSIntegration::touchDevice()
{
return m_touchDevice;
}
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 406470ef8e..80636ab9c6 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -49,7 +49,7 @@
#include <QtCore/private/qcore_mac_p.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qwindow_p.h>
#include <private/qcoregraphics_p.h>
#include <qpa/qwindowsysteminterface.h>
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index f937f7874b..172d6ebcef 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -49,7 +49,7 @@
#include "qiosmenu.h"
#endif
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindow_p.h>
#include <qpa/qwindowsysteminterface_p.h>
@@ -351,13 +351,11 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
{
[super traitCollectionDidChange: previousTraitCollection];
- QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice();
- QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities();
+ QPointingDevice *touchDevice = QIOSIntegration::instance()->touchDevice();
+ QPointingDevice::Capabilities touchCapabilities = touchDevice->capabilities();
- if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
- touchCapabilities |= QTouchDevice::Pressure;
- else
- touchCapabilities &= ~QTouchDevice::Pressure;
+ touchCapabilities.setFlag(QPointingDevice::Capability::Pressure,
+ (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable));
touchDevice->setCapabilities(touchCapabilities);
}
@@ -372,7 +370,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
- (void)handleTouches:(NSSet *)touches withEvent:(UIEvent *)event withState:(Qt::TouchPointState)state withTimestamp:(ulong)timeStamp
{
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
- bool supportsPressure = QIOSIntegration::instance()->touchDevice()->capabilities() & QTouchDevice::Pressure;
+ bool supportsPressure = QIOSIntegration::instance()->touchDevice()->capabilities() & QPointingDevice::Capability::Pressure;
#if QT_CONFIG(tabletevent)
if (m_activePencilTouch && [touches containsObject:m_activePencilTouch]) {
@@ -396,7 +394,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
<< "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0);
QWindowSystemInterface::handleTabletEvent(self.platformWindow->window(), timeStamp, localViewPosition, globalScreenPosition,
// device, pointerType, buttons
- QTabletEvent::RotationStylus, QTabletEvent::Pen, state == Qt::TouchPointReleased ? Qt::NoButton : Qt::LeftButton,
+ int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), state == Qt::TouchPointReleased ? Qt::NoButton : Qt::LeftButton,
// pressure, xTilt, yTilt
pressure, qBound(-60.0, altitudeAngle * azimuth.dx, 60.0), qBound(-60.0, altitudeAngle * azimuth.dy, 60.0),
// tangentialPressure, rotation, z, uid, modifiers
@@ -422,7 +420,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0));
- // FIXME: Do we really need to support QTouchDevice::NormalizedPosition?
+ // FIXME: Do we really need to support QPointingDevice::Capability::NormalizedPosition?
QSize screenSize = self.platformWindow->screen()->geometry().size();
touchPoint.normalPosition = QPointF(globalScreenPosition.x() / screenSize.width(),
globalScreenPosition.y() / screenSize.height());
@@ -434,7 +432,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
// sending a touch press event to Qt, just to have a valid pressure.
touchPoint.pressure = uiTouch.force / uiTouch.maximumPossibleForce;
} else {
- // We don't claim that our touch device supports QTouchDevice::Pressure,
+ // We don't claim that our touch device supports QPointingDevice::Capability::Pressure,
// but fill in a meaningful value in case clients use it anyway.
touchPoint.pressure = (state == Qt::TouchPointReleased) ? 0.0 : 1.0;
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index c9f54c7977..40033d05c9 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -49,7 +49,6 @@
#include <QDebug>
#include <QGuiApplication>
-#include <QTouchDevice>
#include <errno.h>
#include <sys/keycodes.h>
@@ -146,10 +145,10 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration)
, m_focusLostTimer(-1)
{
// Create a touch device
- m_touchDevice = new QTouchDevice;
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+ m_touchDevice = new QPointingDevice;
+ m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
+ m_touchDevice->setCapabilities(QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::Pressure | QPointingDevice::Capability::NormalizedPosition);
+ QWindowSystemInterface::registerInputDevice(m_touchDevice);
// initialize array of touch points
for (int i = 0; i < MaximumTouchPoints; i++) {
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
index b35967610e..c20905fe0d 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h
@@ -97,7 +97,7 @@ private:
QPoint m_lastLocalMousePoint;
Qt::MouseButtons m_lastButtonState;
screen_window_t m_lastMouseWindow;
- QTouchDevice *m_touchDevice;
+ QPointingDevice *m_touchDevice;
QWindowSystemInterface::TouchPoint m_touchPoints[MaximumTouchPoints];
QList<QQnxScreenEventFilter*> m_eventFilters;
QQnxScreenEventThread *m_eventThread;
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index 3e6043b083..77decc970d 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -329,10 +329,10 @@ QWasmEventTranslator::QWasmEventTranslator(QWasmScreen *screen)
, pressedButtons(Qt::NoButton)
, resizeMode(QWasmWindow::ResizeNone)
{
- touchDevice = new QTouchDevice;
- touchDevice->setType(QTouchDevice::TouchScreen);
- touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
+ touchDevice = new QPointingDevice;
+ touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
+ touchDevice->setCapabilities(QPointingDevice::Capability::Position | QPointingDevice::Capability::Area | QPointingDevice::Capability::NormalizedPosition);
+ QWindowSystemInterface::registerInputDevice(touchDevice);
initEventHandlers();
}
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h
index 568ae00732..f6c95770e9 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.h
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h
@@ -35,7 +35,7 @@
#include <QtCore/qpoint.h>
#include <emscripten/html5.h>
#include "qwasmwindow.h"
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qpointingdevice.h>
#include <QHash>
QT_BEGIN_NAMESPACE
@@ -88,7 +88,7 @@ private:
QWasmWindow::ResizeMode resizeMode;
QPoint resizePoint;
QRect resizeStartRect;
- QTouchDevice *touchDevice;
+ QPointingDevice *touchDevice;
quint64 getTimestamp();
Qt::Key m_emDeadKey = Qt::Key_unknown;
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;
};
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 8a4b577d2e..e6feabf79e 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -44,6 +44,7 @@
#include <xcb/randr.h>
#include <QtCore/QTimer>
+#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qtguiglobal_p.h>
#include "qxcbexport.h"
#include <QHash>
@@ -263,10 +264,11 @@ private:
inline bool timeGreaterThan(xcb_timestamp_t a, xcb_timestamp_t b) const
{ return static_cast<int32_t>(a - b) > 0 || b == XCB_CURRENT_TIME; }
- void xi2SetupDevice(void *info, bool removeExisting = true);
+ void xi2SetupSlavePointerDevice(void *info, bool removeExisting = true, QPointingDevice *master = nullptr);
void xi2SetupDevices();
+ // TODO get rid of this: store a smaller struct in QPointingDevicePrivate::extra
struct TouchDeviceData {
- QTouchDevice *qtTouchDevice = nullptr;
+ QPointingDevice *qtTouchDevice = nullptr;
QHash<int, QWindowSystemInterface::TouchPoint> touchPoints;
QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed
struct ValuatorClassInfo {
@@ -290,10 +292,12 @@ private:
void xi2HandleDeviceChangedEvent(void *event);
void xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow);
#if QT_CONFIG(tabletevent)
+ // TODO get rid of this: store a smaller struct in QPointingDevicePrivate::extra
struct TabletData {
int deviceId = 0;
- QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer;
- QTabletEvent::TabletDevice tool = QTabletEvent::Stylus;
+ QString name;
+ QPointingDevice::PointerType pointerType = QPointingDevice::PointerType::Unknown;
+ QInputDevice::DeviceType tool = QInputDevice::DeviceType::Stylus;
Qt::MouseButtons buttons;
qint64 serialId = 0;
bool inProximity = false;
@@ -312,6 +316,7 @@ private:
QVector<TabletData> m_tabletData;
TabletData *tabletDataForDevice(int id);
#endif // QT_CONFIG(tabletevent)
+ // TODO get rid of this: store a smaller struct in QPointingDevicePrivate::extra
struct ScrollingDevice {
int deviceId = 0;
int verticalIndex = 0;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 27a2526df1..f7d7bd755a 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.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.
@@ -41,8 +41,9 @@
#include "qxcbkeyboard.h"
#include "qxcbscreen.h"
#include "qxcbwindow.h"
-#include "qtouchdevice.h"
#include "QtCore/qmetaobject.h"
+#include <QtGui/qpointingdevice.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include <qpa/qwindowsysteminterface_p.h>
#include <QDebug>
#include <cmath>
@@ -107,7 +108,129 @@ static inline qreal fixed3232ToReal(xcb_input_fp3232_t val)
return qreal(val.integral) + qreal(val.frac) / (1ULL << 32);
}
-void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
+#if QT_CONFIG(tabletevent)
+/*!
+ \internal
+ Find the existing QPointingDevice instance representing a particular tablet or stylus;
+ or create and register a new instance if it was not found.
+
+ An instance can be uniquely identified by its \a devType, \a pointerType and \a uniqueId.
+ The rest of the arguments are necessary to create a new instance.
+
+ If the instance represents a stylus, the instance representing the tablet
+ itself must be given as \a master. Otherwise, \a master must be the xinput
+ master device (core pointer) to which the tablet belongs. It should not be
+ null, because \a master is also the QObject::parent() for memory management.
+
+ Proximity events have incomplete information. So as a side effect, if an
+ existing instance is found, it is updated with the given \a usbId and
+ \a toolId, and the seat ID of \a master, in case those values were only
+ now discovered, or the seat assignment changed (?).
+*/
+static const QPointingDevice *tabletToolInstance(QPointingDevice *master, const QString &tabletName,
+ qint64 id, quint32 usbId, quint32 toolId, qint64 uniqueId,
+ QPointingDevice::PointerType pointerTypeOverride = QPointingDevice::PointerType::Unknown,
+ QPointingDevice::Capabilities capsOverride = QInputDevice::Capability::None)
+{
+ QInputDevice::DeviceType devType = QInputDevice::DeviceType::Stylus;
+ QPointingDevice::PointerType pointerType = QPointingDevice::PointerType::Pen;
+ QPointingDevice::Capabilities caps = QInputDevice::Capability::Position |
+ QInputDevice::Capability::Pressure |
+ QInputDevice::Capability::MouseEmulation |
+ QInputDevice::Capability::Hover |
+ capsOverride;
+ int buttonCount = 3; // the tip, plus two barrel buttons
+ // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c
+ // TODO yeah really, there are many more now so this needs updating
+ switch (toolId) {
+ case 0xd12:
+ case 0x912:
+ case 0x112:
+ case 0x913: /* Intuos3 Airbrush */
+ case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
+ case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
+ devType = QInputDevice::DeviceType::Airbrush;
+ caps.setFlag(QInputDevice::Capability::XTilt);
+ caps.setFlag(QInputDevice::Capability::YTilt);
+ caps.setFlag(QInputDevice::Capability::TangentialPressure);
+ buttonCount = 2;
+ break;
+ case 0x91b: /* Intuos3 Airbrush Eraser */
+ case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
+ case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
+ devType = QInputDevice::DeviceType::Airbrush;
+ pointerType = QPointingDevice::PointerType::Eraser;
+ caps.setFlag(QInputDevice::Capability::XTilt);
+ caps.setFlag(QInputDevice::Capability::YTilt);
+ caps.setFlag(QInputDevice::Capability::TangentialPressure);
+ buttonCount = 2;
+ break;
+ case 0x007: /* Mouse 4D and 2D */
+ case 0x09c:
+ case 0x094:
+ // TODO set something to indicate a multi-dimensional capability:
+ // Capability::3D or 4D or QPointingDevice::setMaximumDimensions()?
+ devType = QInputDevice::DeviceType::Mouse;
+ buttonCount = 5; // TODO only if it's a 4D Mouse
+ break;
+ case 0x017: /* Intuos3 2D Mouse */
+ case 0x806: /* Intuos4 Mouse */
+ devType = QInputDevice::DeviceType::Mouse;
+ break;
+ case 0x096: /* Lens cursor */
+ case 0x097: /* Intuos3 Lens cursor */
+ case 0x006: /* Intuos4 Lens cursor */
+ devType = QInputDevice::DeviceType::Puck;
+ break;
+ case 0x885: /* Intuos3 Art Pen (Marker Pen) */
+ case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
+ caps.setFlag(QInputDevice::Capability::XTilt);
+ caps.setFlag(QInputDevice::Capability::YTilt);
+ caps.setFlag(QInputDevice::Capability::Rotation);
+ buttonCount = 1;
+ break;
+ case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
+ pointerType = QPointingDevice::PointerType::Eraser;
+ caps.setFlag(QInputDevice::Capability::XTilt);
+ caps.setFlag(QInputDevice::Capability::YTilt);
+ caps.setFlag(QInputDevice::Capability::Rotation);
+ buttonCount = 1;
+ break;
+ case 0:
+ pointerType = QPointingDevice::PointerType::Unknown;
+ break;
+ }
+ if (pointerTypeOverride != QPointingDevice::PointerType::Unknown)
+ pointerType = pointerTypeOverride;
+ const QPointingDevice *ret = QPointingDevice::tabletDevice(devType, pointerType, QPointingDeviceUniqueId::fromNumericId(uniqueId));
+ if (!ret) {
+ ret = new QPointingDevice(tabletName, id, devType, pointerType, caps, 1, buttonCount,
+ master ? master->seatName() : QString(),
+ QPointingDeviceUniqueId::fromNumericId(uniqueId), master);
+ QWindowSystemInterface::registerInputDevice(ret);
+ }
+ QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(ret));
+ devPriv->busId = QString::number(usbId, 16);
+ devPriv->toolId = toolId;
+ if (master)
+ devPriv->seatName = master->seatName();
+ return ret;
+}
+
+static const char *toolName(QInputDevice::DeviceType tool) {
+ static const QMetaObject *metaObject = qt_getEnumMetaObject(tool);
+ static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(tool)));
+ return me.valueToKey(int(tool));
+}
+
+static const char *pointerTypeName(QPointingDevice::PointerType ptype) {
+ static const QMetaObject *metaObject = qt_getEnumMetaObject(ptype);
+ static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(ptype)));
+ return me.valueToKey(int(ptype));
+}
+#endif
+
+void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting, QPointingDevice *master)
{
auto *deviceInfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info);
if (removeExisting) {
@@ -128,6 +251,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
TabletData tabletData;
#endif
ScrollingDevice scrollingDevice;
+ int buttonCount = 32;
auto classes_it = xcb_input_xi_device_info_classes_iterator(deviceInfo);
for (; classes_it.rem; xcb_input_device_class_next(&classes_it)) {
xcb_input_device_class_t *classinfo = classes_it.data;
@@ -183,6 +307,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
if ((!label6 || qatom(label6) == QXcbAtom::ButtonHorizWheelLeft) && (!label7 || qatom(label7) == QXcbAtom::ButtonHorizWheelRight))
scrollingDevice.legacyOrientations |= Qt::Horizontal;
}
+ buttonCount = bci->num_buttons;
qCDebug(lcQpaXInputDevices, " has %d buttons", bci->num_buttons);
break;
}
@@ -207,42 +332,43 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
// But we need to be careful not to take the touch and tablet-button devices as tablets.
QByteArray name = QByteArray(xcb_input_xi_device_info_name(deviceInfo),
- xcb_input_xi_device_info_name_length(deviceInfo)).toLower();
+ xcb_input_xi_device_info_name_length(deviceInfo));
+ QByteArray nameLower = name.toLower();
QString dbgType = QLatin1String("UNKNOWN");
- if (name.contains("eraser")) {
+ if (nameLower.contains("eraser")) {
isTablet = true;
- tabletData.pointerType = QTabletEvent::Eraser;
+ tabletData.pointerType = QPointingDevice::PointerType::Eraser;
dbgType = QLatin1String("eraser");
- } else if (name.contains("cursor") && !(name.contains("cursor controls") && name.contains("trackball"))) {
+ } else if (nameLower.contains("cursor") && !(nameLower.contains("cursor controls") && nameLower.contains("trackball"))) {
isTablet = true;
- tabletData.pointerType = QTabletEvent::Cursor;
+ tabletData.pointerType = QPointingDevice::PointerType::Cursor;
dbgType = QLatin1String("cursor");
- } else if (name.contains("wacom") && name.contains("finger touch")) {
+ } else if (nameLower.contains("wacom") && nameLower.contains("finger touch")) {
isTablet = false;
- } else if ((name.contains("pen") || name.contains("stylus")) && isTablet) {
- tabletData.pointerType = QTabletEvent::Pen;
+ } else if ((nameLower.contains("pen") || nameLower.contains("stylus")) && isTablet) {
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
- } else if (name.contains("wacom") && isTablet && !name.contains("touch")) {
+ } else if (nameLower.contains("wacom") && isTablet && !nameLower.contains("touch")) {
// combined device (evdev) rather than separate pen/eraser (wacom driver)
- tabletData.pointerType = QTabletEvent::Pen;
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
- } else if (name.contains("aiptek") /* && device == QXcbAtom::KEYBOARD */) {
+ } else if (nameLower.contains("aiptek") /* && device == QXcbAtom::KEYBOARD */) {
// some "Genius" tablets
isTablet = true;
- tabletData.pointerType = QTabletEvent::Pen;
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
- } else if (name.contains("waltop") && name.contains("tablet")) {
+ } else if (nameLower.contains("waltop") && nameLower.contains("tablet")) {
// other "Genius" tablets
// WALTOP International Corp. Slim Tablet
isTablet = true;
- tabletData.pointerType = QTabletEvent::Pen;
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
- } else if (name.contains("uc-logic") && isTablet) {
- tabletData.pointerType = QTabletEvent::Pen;
+ } else if (nameLower.contains("uc-logic") && isTablet) {
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
- } else if (name.contains("ugee")) {
+ } else if (nameLower.contains("ugee")) {
isTablet = true;
- tabletData.pointerType = QTabletEvent::Pen;
+ tabletData.pointerType = QPointingDevice::PointerType::Pen;
dbgType = QLatin1String("pen");
} else {
isTablet = false;
@@ -250,8 +376,20 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
if (isTablet) {
tabletData.deviceId = deviceInfo->deviceid;
+ tabletData.name = QLatin1String(name);
m_tabletData.append(tabletData);
qCDebug(lcQpaXInputDevices) << " it's a tablet with pointer type" << dbgType;
+ QPointingDevice::Capabilities capsOverride = QInputDevice::Capability::None;
+ if (tabletData.valuatorInfo.contains(QXcbAtom::AbsTiltX))
+ capsOverride.setFlag(QInputDevice::Capability::XTilt);
+ if (tabletData.valuatorInfo.contains(QXcbAtom::AbsTiltY))
+ capsOverride.setFlag(QInputDevice::Capability::YTilt);
+ // TODO can we get USB ID?
+ Q_ASSERT(deviceInfo->deviceid == tabletData.deviceId);
+ const QPointingDevice *dev = tabletToolInstance(master,
+ tabletData.name, deviceInfo->deviceid, 0, 0, tabletData.serialId,
+ tabletData.pointerType, capsOverride);
+ Q_ASSERT(dev);
}
#endif // QT_CONFIG(tabletevent)
@@ -266,18 +404,28 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
if (!isTablet) {
TouchDeviceData *dev = populateTouchDevices(deviceInfo);
if (dev && lcQpaXInputDevices().isDebugEnabled()) {
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchScreen)
+ if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen)
qCDebug(lcQpaXInputDevices, " it's a touchscreen with type %d capabilities 0x%X max touch points %d",
- dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
- dev->qtTouchDevice->maximumTouchPoints());
- else if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad)
+ int(dev->qtTouchDevice->type()), qint32(dev->qtTouchDevice->capabilities()),
+ dev->qtTouchDevice->maximumPoints());
+ else if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad)
qCDebug(lcQpaXInputDevices, " it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f",
- dev->qtTouchDevice->type(), (unsigned int)dev->qtTouchDevice->capabilities(),
- dev->qtTouchDevice->maximumTouchPoints(),
+ int(dev->qtTouchDevice->type()), qint32(dev->qtTouchDevice->capabilities()),
+ dev->qtTouchDevice->maximumPoints(),
dev->size.width(), dev->size.height());
}
}
+ if (!QInputDevicePrivate::fromId(deviceInfo->deviceid)) {
+ qCDebug(lcQpaXInputDevices) << " it's a mouse";
+ QInputDevice::Capabilities caps = QInputDevice::Capability::Position | QInputDevice::Capability::Hover;
+ if (scrollingDevice.orientations || scrollingDevice.legacyOrientations)
+ caps.setFlag(QInputDevice::Capability::Scroll);
+ QWindowSystemInterface::registerInputDevice(new QPointingDevice(
+ QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo)), deviceInfo->deviceid,
+ QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
+ caps, 1, buttonCount, (master ? master->seatName() : QString()), QPointingDeviceUniqueId(), master));
+ }
}
void QXcbConnection::xi2SetupDevices()
@@ -295,16 +443,56 @@ void QXcbConnection::xi2SetupDevices()
return;
}
+ // XInput doesn't provide a way to identify "seats"; but each device has an attachment to another device.
+ // So we make up a seatId: master-keyboard-id << 16 | master-pointer-id.
+
auto it = xcb_input_xi_query_device_infos_iterator(reply.get());
for (; it.rem; xcb_input_xi_device_info_next(&it)) {
xcb_input_xi_device_info_t *deviceInfo = it.data;
- if (deviceInfo->type == XCB_INPUT_DEVICE_TYPE_MASTER_POINTER) {
+ switch (deviceInfo->type) {
+ case XCB_INPUT_DEVICE_TYPE_MASTER_KEYBOARD: {
+ auto dev = new QInputDevice(QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo)),
+ deviceInfo->deviceid, QInputDevice::DeviceType::Keyboard,
+ QString::number(deviceInfo->attachment << 16 | deviceInfo->deviceid, 16), this);
+ QWindowSystemInterface::registerInputDevice(dev);
+ } break;
+ case XCB_INPUT_DEVICE_TYPE_MASTER_POINTER: {
m_xiMasterPointerIds.append(deviceInfo->deviceid);
+ auto dev = new QPointingDevice(QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo)), deviceInfo->deviceid,
+ QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
+ QInputDevice::Capability::Position | QInputDevice::Capability::Scroll | QInputDevice::Capability::Hover,
+ 1, 32, QString::number(deviceInfo->attachment << 16 | deviceInfo->deviceid, 16), QPointingDeviceUniqueId(), this);
+ QWindowSystemInterface::registerInputDevice(dev);
continue;
+ } break;
+ default:
+ break;
+ }
+ }
+
+ it = xcb_input_xi_query_device_infos_iterator(reply.get());
+ for (; it.rem; xcb_input_xi_device_info_next(&it)) {
+ xcb_input_xi_device_info_t *deviceInfo = it.data;
+ switch (deviceInfo->type) {
+ case XCB_INPUT_DEVICE_TYPE_MASTER_KEYBOARD:
+ case XCB_INPUT_DEVICE_TYPE_MASTER_POINTER:
+ // already registered
+ break;
+ case XCB_INPUT_DEVICE_TYPE_SLAVE_POINTER: {
+ QInputDevice *master = const_cast<QInputDevice *>(QInputDevicePrivate::fromId(deviceInfo->attachment));
+ Q_ASSERT(master);
+ xi2SetupSlavePointerDevice(deviceInfo, false, qobject_cast<QPointingDevice *>(master));
+ } break;
+ case XCB_INPUT_DEVICE_TYPE_SLAVE_KEYBOARD: {
+ QInputDevice *master = const_cast<QInputDevice *>(QInputDevicePrivate::fromId(deviceInfo->attachment));
+ Q_ASSERT(master);
+ QWindowSystemInterface::registerInputDevice(new QInputDevice(
+ QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo)), deviceInfo->deviceid,
+ QInputDevice::DeviceType::Keyboard, master->seatName(), master));
+ } break;
+ case XCB_INPUT_DEVICE_TYPE_FLOATING_SLAVE:
+ break;
}
- // only slave pointer devices are relevant here
- if (deviceInfo->type == XCB_INPUT_DEVICE_TYPE_SLAVE_POINTER)
- xi2SetupDevice(deviceInfo, false);
}
if (m_xiMasterPointerIds.size() > 1)
@@ -423,14 +611,14 @@ QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info)
{
- auto *deviceinfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info);
- QTouchDevice::Capabilities caps;
- int type = -1;
+ auto *deviceInfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info);
+ QPointingDevice::Capabilities caps;
+ QInputDevice::DeviceType type = QInputDevice::DeviceType::Unknown;
int maxTouchPoints = 1;
bool isTouchDevice = false;
bool hasRelativeCoords = false;
TouchDeviceData dev;
- auto classes_it = xcb_input_xi_device_info_classes_iterator(deviceinfo);
+ auto classes_it = xcb_input_xi_device_info_classes_iterator(deviceInfo);
for (; classes_it.rem; xcb_input_device_class_next(&classes_it)) {
xcb_input_device_class_t *classinfo = classes_it.data;
switch (classinfo->type) {
@@ -440,10 +628,10 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
qCDebug(lcQpaXInputDevices, " has touch class with mode %d", tci->mode);
switch (tci->mode) {
case XCB_INPUT_TOUCH_MODE_DEPENDENT:
- type = QTouchDevice::TouchPad;
+ type = QInputDevice::DeviceType::TouchPad;
break;
case XCB_INPUT_TOUCH_MODE_DIRECT:
- type = QTouchDevice::TouchScreen;
+ type = QInputDevice::DeviceType::TouchScreen;
break;
}
break;
@@ -463,13 +651,13 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
// for now just prevent a division by zero
const int vciResolution = vci->resolution ? vci->resolution : 1;
if (valuatorAtom == QXcbAtom::AbsMTPositionX)
- caps |= QTouchDevice::Position | QTouchDevice::NormalizedPosition;
+ caps |= QInputDevice::Capability::Position | QInputDevice::Capability::NormalizedPosition;
else if (valuatorAtom == QXcbAtom::AbsMTTouchMajor)
- caps |= QTouchDevice::Area;
+ caps |= QInputDevice::Capability::Area;
else if (valuatorAtom == QXcbAtom::AbsMTOrientation)
dev.providesTouchOrientation = true;
else if (valuatorAtom == QXcbAtom::AbsMTPressure || valuatorAtom == QXcbAtom::AbsPressure)
- caps |= QTouchDevice::Pressure;
+ caps |= QInputDevice::Capability::Pressure;
else if (valuatorAtom == QXcbAtom::RelX) {
hasRelativeCoords = true;
dev.size.setWidth((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution);
@@ -477,10 +665,10 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
hasRelativeCoords = true;
dev.size.setHeight((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution);
} else if (valuatorAtom == QXcbAtom::AbsX) {
- caps |= QTouchDevice::Position;
+ caps |= QInputDevice::Capability::Position;
dev.size.setWidth((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution);
} else if (valuatorAtom == QXcbAtom::AbsY) {
- caps |= QTouchDevice::Position;
+ caps |= QInputDevice::Capability::Position;
dev.size.setHeight((fixed3232ToReal(vci->max) - fixed3232ToReal(vci->min)) * 1000.0 / vciResolution);
}
break;
@@ -489,29 +677,30 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
break;
}
}
- if (type < 0 && caps && hasRelativeCoords) {
- type = QTouchDevice::TouchPad;
+ if (type == QInputDevice::DeviceType::Unknown && caps && hasRelativeCoords) {
+ type = QInputDevice::DeviceType::TouchPad;
if (dev.size.width() < 10 || dev.size.height() < 10 ||
dev.size.width() > 10000 || dev.size.height() > 10000)
dev.size = QSizeF(130, 110);
}
- if (!isAtLeastXI22() || type == QTouchDevice::TouchPad)
- caps |= QTouchDevice::MouseEmulation;
-
- if (type >= QTouchDevice::TouchScreen && type <= QTouchDevice::TouchPad) {
- dev.qtTouchDevice = new QTouchDevice;
- dev.qtTouchDevice->setName(QString::fromUtf8(xcb_input_xi_device_info_name(deviceinfo),
- xcb_input_xi_device_info_name_length(deviceinfo)));
- dev.qtTouchDevice->setType((QTouchDevice::DeviceType)type);
- dev.qtTouchDevice->setCapabilities(caps);
- dev.qtTouchDevice->setMaximumTouchPoints(maxTouchPoints);
+ if (!isAtLeastXI22() || type == QInputDevice::DeviceType::TouchPad)
+ caps |= QInputDevice::Capability::MouseEmulation;
+
+ if (type == QInputDevice::DeviceType::TouchScreen || type == QInputDevice::DeviceType::TouchPad) {
+ QInputDevice *master = const_cast<QInputDevice *>(QInputDevicePrivate::fromId(deviceInfo->attachment));
+ Q_ASSERT(master);
+ dev.qtTouchDevice = new QPointingDevice(QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo),
+ xcb_input_xi_device_info_name_length(deviceInfo)),
+ deviceInfo->deviceid,
+ type, QPointingDevice::PointerType::Finger, caps, maxTouchPoints, 0,
+ master->seatName(), QPointingDeviceUniqueId(), master);
if (caps != 0)
- QWindowSystemInterface::registerTouchDevice(dev.qtTouchDevice);
- m_touchDevices[deviceinfo->deviceid] = dev;
+ QWindowSystemInterface::registerInputDevice(dev.qtTouchDevice);
+ m_touchDevices[deviceInfo->deviceid] = dev;
isTouchDevice = true;
}
- return isTouchDevice ? &m_touchDevices[deviceinfo->deviceid] : nullptr;
+ return isTouchDevice ? &m_touchDevices[deviceInfo->deviceid] : nullptr;
}
static inline qreal fixed1616ToReal(xcb_input_fp1616_t val)
@@ -564,6 +753,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
#if QT_CONFIG(tabletevent)
if (!xiEnterEvent) {
+ // TODO we need the UID here; tabletDataForDevice doesn't have enough to go on (?)
QXcbConnection::TabletData *tablet = tabletDataForDevice(sourceDeviceId);
if (tablet && xi2HandleTabletEvent(event, tablet))
return;
@@ -616,7 +806,7 @@ bool QXcbConnection::xi2MouseEventsDisabled() const
bool QXcbConnection::isTouchScreen(int id)
{
auto device = touchDeviceForId(id);
- return device && device->qtTouchDevice->type() == QTouchDevice::TouchScreen;
+ return device && device->qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen;
}
void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindow)
@@ -728,7 +918,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
}
break;
case XCB_INPUT_TOUCH_UPDATE:
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
+ if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
@@ -738,11 +928,11 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
touchPoint.state = Qt::TouchPointMoved;
} else if (touchPoint.area.center() != QPoint(x, y)) {
touchPoint.state = Qt::TouchPointMoved;
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad)
+ if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad)
dev->pointPressedPosition[touchPoint.id] = QPointF(x, y);
}
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchScreen &&
+ if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen &&
xiDeviceEvent->event == m_startSystemMoveResizeInfo.window &&
xiDeviceEvent->sourceid == m_startSystemMoveResizeInfo.deviceid &&
xiDeviceEvent->detail == m_startSystemMoveResizeInfo.pointid) {
@@ -758,7 +948,7 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
break;
case XCB_INPUT_TOUCH_END:
touchPoint.state = Qt::TouchPointReleased;
- if (dev->qtTouchDevice->type() == QTouchDevice::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
+ if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad && dev->pointPressedPosition.value(touchPoint.id) == QPointF(x, y)) {
qreal dx = (nx - dev->firstPressedNormalPosition.x()) *
dev->size.width() * screen->geometry().width() / screen->physicalSize().width();
qreal dy = (ny - dev->firstPressedNormalPosition.y()) *
@@ -790,7 +980,7 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge
QHash<int, TouchDeviceData>::const_iterator devIt = m_touchDevices.constBegin();
for (; devIt != m_touchDevices.constEnd(); ++devIt) {
TouchDeviceData deviceData = devIt.value();
- if (deviceData.qtTouchDevice->type() == QTouchDevice::TouchScreen) {
+ if (deviceData.qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen) {
auto pointIt = deviceData.touchPoints.constBegin();
for (; pointIt != deviceData.touchPoints.constEnd(); ++pointIt) {
Qt::TouchPointState state = pointIt.value().state;
@@ -893,7 +1083,7 @@ void QXcbConnection::xi2HandleDeviceChangedEvent(void *event)
if (!reply || reply->num_infos <= 0)
return;
auto it = xcb_input_xi_query_device_infos_iterator(reply.get());
- xi2SetupDevice(it.data);
+ xi2SetupSlavePointerDevice(it.data);
break;
}
case XCB_INPUT_CHANGE_REASON_SLAVE_SWITCH: {
@@ -1081,51 +1271,6 @@ Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b)
}
#if QT_CONFIG(tabletevent)
-static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) {
- // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c
- switch (toolId) {
- case 0xd12:
- case 0x912:
- case 0x112:
- case 0x913: /* Intuos3 Airbrush */
- case 0x91b: /* Intuos3 Airbrush Eraser */
- case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
- case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
- case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
- case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
- return QTabletEvent::Airbrush;
- case 0x007: /* Mouse 4D and 2D */
- case 0x09c:
- case 0x094:
- return QTabletEvent::FourDMouse;
- case 0x017: /* Intuos3 2D Mouse */
- case 0x806: /* Intuos4 Mouse */
- case 0x096: /* Lens cursor */
- case 0x097: /* Intuos3 Lens cursor */
- case 0x006: /* Intuos4 Lens cursor */
- return QTabletEvent::Puck;
- case 0x885: /* Intuos3 Art Pen (Marker Pen) */
- case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
- case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
- return QTabletEvent::RotationStylus;
- case 0:
- return QTabletEvent::NoDevice;
- }
- return QTabletEvent::Stylus; // Safe default assumption if nonzero
-}
-
-static const char *toolName(QTabletEvent::TabletDevice tool) {
- static const QMetaObject *metaObject = qt_getEnumMetaObject(tool);
- static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(tool)));
- return me.valueToKey(tool);
-}
-
-static const char *pointerTypeName(QTabletEvent::PointerType ptype) {
- static const QMetaObject *metaObject = qt_getEnumMetaObject(ptype);
- static const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(ptype)));
- return me.valueToKey(ptype);
-}
-
bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData)
{
bool handled = true;
@@ -1175,27 +1320,35 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
// The property change event informs us which tool is in proximity or which one left proximity.
if (tool) {
+ const QPointingDevice *dev = tabletToolInstance(nullptr, tabletData->name,
+ tabletData->deviceId, ptr[_WACSER_USB_ID], tool,
+ qint64(ptr[_WACSER_TOOL_SERIAL])); // TODO look up the master
tabletData->inProximity = true;
- tabletData->tool = toolIdToTabletDevice(tool);
- tabletData->serialId = qint64(ptr[_WACSER_USB_ID]) << 32 | qint64(ptr[_WACSER_TOOL_SERIAL]);
+ tabletData->tool = dev->type();
+ tabletData->serialId = qint64(ptr[_WACSER_TOOL_SERIAL]);
QWindowSystemInterface::handleTabletEnterProximityEvent(ev->time,
- tabletData->tool, tabletData->pointerType, tabletData->serialId);
+ int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId);
} else {
- tabletData->inProximity = false;
- tabletData->tool = toolIdToTabletDevice(ptr[_WACSER_LAST_TOOL_ID]);
+ tool = ptr[_WACSER_LAST_TOOL_ID];
// Workaround for http://sourceforge.net/p/linuxwacom/bugs/246/
// e.g. on Thinkpad Helix, tool ID will be 0 and serial will be 1
- if (!tabletData->tool)
- tabletData->tool = toolIdToTabletDevice(ptr[_WACSER_LAST_TOOL_SERIAL]);
- tabletData->serialId = qint64(ptr[_WACSER_USB_ID]) << 32 | qint64(ptr[_WACSER_LAST_TOOL_SERIAL]);
+ if (!tool)
+ tool = ptr[_WACSER_LAST_TOOL_SERIAL];
+ const QInputDevice *dev = QInputDevicePrivate::fromId(tabletData->deviceId);
+ Q_ASSERT(dev);
+ tabletData->tool = dev->type();
+ tabletData->inProximity = false;
+ tabletData->serialId = qint64(ptr[_WACSER_LAST_TOOL_SERIAL]);
+ // TODO why doesn't it just take QPointingDevice*
QWindowSystemInterface::handleTabletLeaveProximityEvent(ev->time,
- tabletData->tool, tabletData->pointerType, tabletData->serialId);
+ int(tabletData->tool), int(tabletData->pointerType), tabletData->serialId);
}
// TODO maybe have a hash of tabletData->deviceId to device data so we can
// look up the tablet name here, and distinguish multiple tablets
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
- qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x %s",
- tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
+ qCDebug(lcQpaXInputDevices, "XI2 proximity change on tablet %d %s (USB %x): last tool: %x id %x current tool: %x id %x %s",
+ tabletData->deviceId, qPrintable(tabletData->name), ptr[_WACSER_USB_ID],
+ ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], toolName(tabletData->tool));
}
}
@@ -1216,6 +1369,7 @@ inline qreal scaleOneValuator(qreal normValue, qreal screenMin, qreal screenSize
return screenMin + normValue * screenSize;
}
+// TODO QPointingDevice not TabletData
void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletData)
{
auto *ev = reinterpret_cast<const qt_xcb_input_device_event_t *>(event);
@@ -1274,10 +1428,10 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
break;
case QXcbAtom::AbsWheel:
switch (tabletData->tool) {
- case QTabletEvent::Airbrush:
+ case QInputDevice::DeviceType::Airbrush:
tangentialPressure = normalizedValue * 2.0 - 1.0; // Convert 0..1 range to -1..+1 range
break;
- case QTabletEvent::RotationStylus:
+ case QInputDevice::DeviceType::Stylus:
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
@@ -1290,15 +1444,15 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
}
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
- qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %s type %s seq %d detail %d time %d "
+ 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",
- tabletData->deviceId, toolName(tabletData->tool), pointerTypeName(tabletData->pointerType),
+ tabletData->deviceId, toolName(tabletData->tool), tabletData->serialId, pointerTypeName(tabletData->pointerType),
ev->sequence, ev->detail, ev->time,
local.x(), local.y(), global.x(), global.y(),
(int)tabletData->buttons, pressure, xTilt, yTilt, rotation, (int)modifiers);
QWindowSystemInterface::handleTabletEvent(window, ev->time, local, global,
- tabletData->tool, tabletData->pointerType,
+ int(tabletData->tool), int(tabletData->pointerType),
tabletData->buttons, pressure,
xTilt, yTilt, tangentialPressure,
rotation, 0, tabletData->serialId, modifiers);