/src/qtbase/src/gui/kernel/qpointingdevice.h
Line | Count | Source |
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 QPOINTINGDEVICE_H |
6 | | #define QPOINTINGDEVICE_H |
7 | | |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtCore/qobject.h> |
10 | | #include <QtGui/qinputdevice.h> |
11 | | |
12 | | QT_BEGIN_NAMESPACE |
13 | | |
14 | | class QDebug; |
15 | | class QEventPoint; |
16 | | class QPointerEvent; |
17 | | class QPointingDevicePrivate; |
18 | | class QPointerEvent; |
19 | | class QScreen; |
20 | | |
21 | | class Q_GUI_EXPORT QPointingDeviceUniqueId |
22 | | { |
23 | | Q_GADGET |
24 | | Q_PROPERTY(qint64 numericId READ numericId CONSTANT) |
25 | | public: |
26 | | Q_ALWAYS_INLINE |
27 | 0 | constexpr QPointingDeviceUniqueId() noexcept : m_numericId(-1) {} |
28 | | // compiler-generated copy/move ctor/assignment operators are ok! |
29 | | // compiler-generated dtor is ok! |
30 | | |
31 | | static QPointingDeviceUniqueId fromNumericId(qint64 id); |
32 | | |
33 | 0 | Q_ALWAYS_INLINE constexpr bool isValid() const noexcept { return m_numericId != -1; } |
34 | | qint64 numericId() const noexcept; |
35 | | |
36 | | private: |
37 | | friend bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept |
38 | 0 | { return lhs.numericId() == rhs.numericId(); } |
39 | | friend bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept |
40 | 0 | { return lhs.numericId() != rhs.numericId(); } |
41 | | |
42 | | // TODO: for TUIO 2, or any other type of complex token ID, an internal |
43 | | // array (or hash) can be added to hold additional properties. |
44 | | // In this case, m_numericId will then turn into an index into that array (or hash). |
45 | | qint64 m_numericId; |
46 | | }; |
47 | | Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_RELOCATABLE_TYPE); |
48 | | |
49 | | Q_GUI_EXPORT size_t qHash(QPointingDeviceUniqueId key, size_t seed = 0) noexcept; |
50 | | |
51 | | class Q_GUI_EXPORT QPointingDevice : public QInputDevice |
52 | | { |
53 | | Q_OBJECT |
54 | | Q_DECLARE_PRIVATE(QPointingDevice) |
55 | | Q_PROPERTY(PointerType pointerType READ pointerType CONSTANT) |
56 | | Q_PROPERTY(int maximumPoints READ maximumPoints CONSTANT) |
57 | | Q_PROPERTY(int buttonCount READ buttonCount CONSTANT) |
58 | | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT) |
59 | | |
60 | | public: |
61 | | enum class PointerType { |
62 | | Unknown = 0, |
63 | | Generic = 0x0001, // mouse or similar |
64 | | Finger = 0x0002, // touchscreen or pad |
65 | | Pen = 0x0004, // stylus on a tablet |
66 | | Eraser = 0x0008, // eraser end of a stylus |
67 | | Cursor = 0x0010, // digitizer with crosshairs |
68 | | Palm = 0x0020, // palm |
69 | | AllPointerTypes = 0x7FFF |
70 | | }; |
71 | | Q_DECLARE_FLAGS(PointerTypes, PointerType) |
72 | | Q_FLAG(PointerTypes) |
73 | | |
74 | | enum GrabTransition { |
75 | | GrabPassive = 0x01, |
76 | | UngrabPassive = 0x02, |
77 | | CancelGrabPassive = 0x03, |
78 | | OverrideGrabPassive = 0x04, |
79 | | GrabExclusive = 0x10, |
80 | | UngrabExclusive = 0x20, |
81 | | CancelGrabExclusive = 0x30, |
82 | | }; |
83 | | Q_ENUM(GrabTransition) |
84 | | |
85 | | QPointingDevice(QObject *parent = nullptr); |
86 | | ~QPointingDevice(); |
87 | | QPointingDevice(const QString &name, qint64 systemId, QInputDevice::DeviceType devType, |
88 | | PointerType pType, Capabilities caps, int maxPoints, int buttonCount, |
89 | | const QString &seatName = QString(), |
90 | | QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId(), |
91 | | QObject *parent = nullptr); |
92 | | |
93 | | #if QT_DEPRECATED_SINCE(6, 0) |
94 | | QT_DEPRECATED_VERSION_X_6_0("Use the constructor") |
95 | | void setType(DeviceType devType); |
96 | | QT_DEPRECATED_VERSION_X_6_0("Use the constructor") |
97 | | void setCapabilities(QInputDevice::Capabilities caps); |
98 | | QT_DEPRECATED_VERSION_X_6_0("Use the constructor") |
99 | | void setMaximumTouchPoints(int c); |
100 | | #endif |
101 | | |
102 | | PointerType pointerType() const; |
103 | | int maximumPoints() const; |
104 | | int buttonCount() const; |
105 | | QPointingDeviceUniqueId uniqueId() const; |
106 | | |
107 | | static const QPointingDevice *primaryPointingDevice(const QString& seatName = QString()); |
108 | | |
109 | | bool operator==(const QPointingDevice &other) const; |
110 | | |
111 | | Q_SIGNALS: |
112 | | #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) |
113 | | void grabChanged(QObject *grabber, GrabTransition transition, |
114 | | const QPointerEvent *event, const QEventPoint &point) const; |
115 | | #else |
116 | | void grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, |
117 | | const QPointerEvent *event, const QEventPoint &point); |
118 | | #endif |
119 | | |
120 | | protected: |
121 | | QPointingDevice(QPointingDevicePrivate &d, QObject *parent); |
122 | | |
123 | | Q_DISABLE_COPY_MOVE(QPointingDevice) |
124 | | }; |
125 | | |
126 | | Q_DECLARE_OPERATORS_FOR_FLAGS(QPointingDevice::PointerTypes) |
127 | | |
128 | | #ifndef QT_NO_DEBUG_STREAM |
129 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QPointingDevice *); |
130 | | #endif |
131 | | |
132 | | //typedef QPointingDevice QTouchDevice; // Qt 5 source compatibility if we need it? or could be "using" |
133 | | |
134 | | QT_END_NAMESPACE |
135 | | |
136 | | #endif // QPOINTINGDEVICE_H |