summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qinputdevice_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-30 11:08:49 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-07 16:14:58 +0000
commitc7c28b340662915a9f8fdb84c0a94c458fe6a290 (patch)
tree2878e2dcff2df2a881853d3e1a08161809c8752e /src/gui/kernel/qinputdevice_p.h
parent8936918a651ac297c91bfd285995993b306347ab (diff)
Separate QPD::tabletDevice into priv tabletDevice and queryTabletDevice
There doesn't seem to be any reason users will need to query tablet devices by their IDs, because every event comes with a complete instance already, and we have QInputDevice::devices() to list them all. QPointingDevicePrivate::tabletDevice() can create a new instance if a matching one is not found (and complains about that); it's intended for use in QtGui, as a way to find the device if it was not part of the QWSI event. Now it sets the parent of those auto-created instances to QCoreApplication to avoid a memory leak. On the other hand, queryTabletDevice() is intended for use in platform plugins that need to check whether an instance exists; but they will take care of creating new instances themselves, and thus have more control over the parent and the details being stored. Now that the systemId can also be given, the search is more likely to have a unique result, on window systems that provide device IDs. Rename id() to systemId() to clarify that it's a system-specific unique device ID of some sort, not the same as the uniqueId that a stylus has. However it seems that in practice, this will often be 0; so clarify that if it's not unique, QInputDevicePrivate::fromId() and queryTabletDevice() may not always find the right instance. Clarify the function usage via comments. Change-Id: I82bb8d1c26eeaf06f07c290828aa17ec4a31646b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qinputdevice_p.h')
-rw-r--r--src/gui/kernel/qinputdevice_p.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/kernel/qinputdevice_p.h b/src/gui/kernel/qinputdevice_p.h
index 53f379f42c..9c4ce5eb69 100644
--- a/src/gui/kernel/qinputdevice_p.h
+++ b/src/gui/kernel/qinputdevice_p.h
@@ -61,17 +61,17 @@ class Q_GUI_EXPORT QInputDevicePrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QInputDevice)
public:
- QInputDevicePrivate(const QString &name, qint64 id, QInputDevice::DeviceType type,
+ QInputDevicePrivate(const QString &name, qint64 winSysId, QInputDevice::DeviceType type,
QInputDevice::Capabilities caps = QInputDevice::Capability::None,
const QString &seatName = QString())
- : name(name), seatName(seatName), id(id), capabilities(caps),
+ : name(name), seatName(seatName), systemId(winSysId), capabilities(caps),
deviceType(type), pointingDeviceType(false)
{
// if the platform doesn't provide device IDs, make one up,
// but try to avoid clashing with OS-provided 32-bit IDs
static qint64 nextId = qint64(1) << 33;
- if (!id)
- id = nextId++;
+ if (!systemId)
+ systemId = nextId++;
}
QString name;
@@ -80,7 +80,7 @@ public:
QRect availableVirtualGeometry;
void *extra = nullptr; // The QPA plugin can store arbitrary device-specific data here
void *qqExtra = nullptr; // Qt Quick can store arbitrary device-specific data here
- qint64 id = 0;
+ qint64 systemId = 0;
qint32 capabilities = static_cast<qint32>(QInputDevice::Capability::None);
QInputDevice::DeviceType deviceType = QInputDevice::DeviceType::Unknown;
qint16 pointingDeviceType : 1; // actually bool, but pack with deviceType
@@ -88,7 +88,7 @@ public:
static void registerDevice(const QInputDevice *dev);
static void unregisterDevice(const QInputDevice *dev);
static bool isRegistered(const QInputDevice *dev);
- static const QInputDevice *fromId(qint64 id); // window system ID (e.g. xinput id), not QPointingDeviceUniqueId
+ static const QInputDevice *fromId(qint64 systemId);
void setAvailableVirtualGeometry(QRect a)
{