Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qinputdevice_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QINPUTDEVICE_P_H
6#define QINPUTDEVICE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include <QtGui/qinputdevice.h>
21#include "private/qobject_p.h"
22
24
25class Q_GUI_EXPORT QInputDevicePrivate : public QObjectPrivate
26{
27 Q_DECLARE_PUBLIC(QInputDevice)
28public:
29 QInputDevicePrivate(const QString &name, qint64 winSysId, QInputDevice::DeviceType type,
30 QInputDevice::Capabilities caps = QInputDevice::Capability::None,
31 const QString &seatName = QString())
32 : name(name), seatName(seatName), systemId(winSysId), capabilities(caps),
33 deviceType(type)
34 {
35 // if the platform doesn't provide device IDs, make one up,
36 // but try to avoid clashing with OS-provided 32-bit IDs
37 static qint64 nextId = qint64(1) << 33;
38 if (!systemId)
39 systemId = nextId++;
40 }
41 ~QInputDevicePrivate() override;
42
43 QString name;
44 QString seatName;
45 QString busId;
46 QRect availableVirtualGeometry;
47 void *qqExtra = nullptr; // Qt Quick can store arbitrary device-specific data here
48 qint64 systemId = 0;
49 QInputDevice::Capabilities capabilities = QInputDevice::Capability::None;
50 QInputDevice::DeviceType deviceType = QInputDevice::DeviceType::Unknown;
51 bool pointingDeviceType = false;
52
53 static void registerDevice(const QInputDevice *dev);
54 static void unregisterDevice(const QInputDevice *dev);
55 static bool isRegistered(const QInputDevice *dev);
56 static const QInputDevice *fromId(qint64 systemId);
57
58 void setAvailableVirtualGeometry(QRect a)
59 {
60 if (a == availableVirtualGeometry)
61 return;
62
63 availableVirtualGeometry = a;
64 setCapabilities(capabilities | QInputDevice::Capability::NormalizedPosition);
65 Q_Q(QInputDevice);
66 Q_EMIT q->availableVirtualGeometryChanged(availableVirtualGeometry);
67 }
68
69 void setCapabilities(QInputDevice::Capabilities c)
70 {
71 if (c == capabilities)
72 return;
73
74 capabilities = c;
75 Q_Q(QInputDevice);
76 Q_EMIT q->capabilitiesChanged(capabilities);
77 }
78
79 inline static QInputDevicePrivate *get(QInputDevice *q)
80 {
81 return static_cast<QInputDevicePrivate *>(QObjectPrivate::get(q));
82 }
83
84 inline static const QInputDevicePrivate *get(const QInputDevice *q)
85 {
86 return static_cast<const QInputDevicePrivate *>(QObjectPrivate::get(q));
87 }
88};
89
90QT_END_NAMESPACE
91
92#endif // QINPUTDEVICE_P_H
The QInputDevice class describes a device from which a QInputEvent originates.
Combined button and popup list for selecting options.