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
qpointingdevice.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 QPOINTINGDEVICE_H
6#define QPOINTINGDEVICE_H
7
8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qobject.h>
10#include <QtGui/qinputdevice.h>
11
13
14class QDebug;
15class QEventPoint;
16class QPointerEvent;
17class QPointingDevicePrivate;
18class QPointerEvent;
19class QScreen;
20
21class Q_GUI_EXPORT QPointingDeviceUniqueId
22{
23 Q_GADGET
24 Q_PROPERTY(qint64 numericId READ numericId CONSTANT)
25public:
26 Q_ALWAYS_INLINE
27 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 Q_ALWAYS_INLINE constexpr bool isValid() const noexcept { return m_numericId != -1; }
34 qint64 numericId() const noexcept;
35
36private:
37 friend bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept
38 { return lhs.numericId() == rhs.numericId(); }
39 friend bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept
40 { 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};
47Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_RELOCATABLE_TYPE);
48
49Q_GUI_EXPORT size_t qHash(QPointingDeviceUniqueId key, size_t seed = 0) noexcept;
50
51class 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
60public:
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 AllPointerTypes = 0x7FFF
69 };
70 Q_DECLARE_FLAGS(PointerTypes, PointerType)
71 Q_FLAG(PointerTypes)
72
73 enum GrabTransition {
74 GrabPassive = 0x01,
75 UngrabPassive = 0x02,
76 CancelGrabPassive = 0x03,
77 OverrideGrabPassive = 0x04,
78 GrabExclusive = 0x10,
79 UngrabExclusive = 0x20,
80 CancelGrabExclusive = 0x30,
81 };
82 Q_ENUM(GrabTransition)
83
84 QPointingDevice(QObject *parent = nullptr);
85 ~QPointingDevice();
86 QPointingDevice(const QString &name, qint64 systemId, QInputDevice::DeviceType devType,
87 PointerType pType, Capabilities caps, int maxPoints, int buttonCount,
88 const QString &seatName = QString(),
89 QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId(),
90 QObject *parent = nullptr);
91
92#if QT_DEPRECATED_SINCE(6, 0)
93 QT_DEPRECATED_VERSION_X_6_0("Use the constructor")
94 void setType(DeviceType devType);
95 QT_DEPRECATED_VERSION_X_6_0("Use the constructor")
96 void setCapabilities(QInputDevice::Capabilities caps);
97 QT_DEPRECATED_VERSION_X_6_0("Use the constructor")
98 void setMaximumTouchPoints(int c);
99#endif
100
101 PointerType pointerType() const;
102 int maximumPoints() const;
103 int buttonCount() const;
104 QPointingDeviceUniqueId uniqueId() const;
105
106 static const QPointingDevice *primaryPointingDevice(const QString& seatName = QString());
107
108 bool operator==(const QPointingDevice &other) const;
109
110Q_SIGNALS:
111#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
112 void grabChanged(QObject *grabber, GrabTransition transition,
113 const QPointerEvent *event, const QEventPoint &point) const;
114#else
115 void grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition,
116 const QPointerEvent *event, const QEventPoint &point);
117#endif
118
119protected:
120 QPointingDevice(QPointingDevicePrivate &d, QObject *parent);
121
122 Q_DISABLE_COPY_MOVE(QPointingDevice)
123};
124
125Q_DECLARE_OPERATORS_FOR_FLAGS(QPointingDevice::PointerTypes)
126
127#ifndef QT_NO_DEBUG_STREAM
128Q_GUI_EXPORT QDebug operator<<(QDebug, const QPointingDevice *);
129#endif
130
131//typedef QPointingDevice QTouchDevice; // Qt 5 source compatibility if we need it? or could be "using"
132
133QT_END_NAMESPACE
134
135#endif // QPOINTINGDEVICE_H
The QClipboard class provides access to the window system clipboard.
Definition qclipboard.h:21
\inmodule QtCore\reentrant
Definition qdatastream.h:50
\reentrant
Definition qfont.h:22
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
QInputDeviceManager acts as a communication hub between QtGui and the input handlers.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:20
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
The QPlatformTheme class allows customizing the UI based on themes.
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:177
The QStyleHints class contains platform specific hints and settings. \inmodule QtGui.
Definition qstylehints.h:18
\inmodule QtGui
Definition qwindow.h:64
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
#define qApp
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
static bool needsWindowBlockedEvent(const QWindow *w)
Q_CORE_EXPORT void qt_call_post_routines()
static void init_plugins(const QList< QByteArray > &pluginList)
static void initFontUnlocked()
static void clearFontUnlocked()
void qRegisterGuiVariant()
static Q_CONSTINIT unsigned applicationResourceFlags
static Q_CONSTINIT int touchDoubleTapDistance
static QWindowGeometrySpecification windowGeometrySpecification
static bool qt_detectRTLLanguage()
Q_CONSTINIT Q_GUI_EXPORT bool qt_is_tty_app
static Q_CONSTINIT bool force_reverse
static Q_CONSTINIT int mouseDoubleClickDistance
#define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER
static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv)
static void initThemeHints()
static int nextGeometryToken(const QByteArray &a, int &pos, char *op)
#define CHECK_QAPP_INSTANCE(...)
ApplicationResourceFlags
@ ApplicationFontExplicitlySet
static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked)
#define qGuiApp
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
QDebug Q_GUI_EXPORT & operator<<(QDebug &s, const QVectorPath &path)
void applyTo(QWindow *window) const
static QWindowGeometrySpecification fromArgument(const QByteArray &a)