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_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 QPOINTINGDEVICE_P_H
6#define QPOINTINGDEVICE_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 <QtCore/qloggingcategory.h>
20#include <QtGui/private/qevent_p.h>
21#include <QtGui/qpointingdevice.h>
22#include <QtGui/private/qtguiglobal_p.h>
23#include <QtGui/private/qinputdevice_p.h>
24
25#include <QtCore/qpointer.h>
26#include <QtCore/private/qflatmap_p.h>
27
29
30Q_DECLARE_LOGGING_CATEGORY(lcPointerGrab);
31
32class Q_GUI_EXPORT QPointingDevicePrivate : public QInputDevicePrivate
33{
34 Q_DECLARE_PUBLIC(QPointingDevice)
35public:
36 QPointingDevicePrivate(const QString &name, qint64 id, QInputDevice::DeviceType type,
37 QPointingDevice::PointerType pType, QPointingDevice::Capabilities caps,
38 int maxPoints, int buttonCount,
39 const QString &seatName = QString(),
40 QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId())
41 : QInputDevicePrivate(name, id, type, caps, seatName),
42 uniqueId(uniqueId),
43 maximumTouchPoints(qint8(maxPoints)), buttonCount(qint8(buttonCount)),
44 pointerType(pType)
45 {
46 pointingDeviceType = true;
47 activePoints.reserve(maxPoints);
48 }
49 ~QPointingDevicePrivate() override;
50
51 void sendTouchCancelEvent(QTouchEvent *cancelEvent);
52
53 /*! \internal
54 This struct (stored in activePoints) holds persistent state between event deliveries.
55 */
56 struct EventPointData {
57 QEventPoint eventPoint;
58 QPointer<QObject> exclusiveGrabber;
59 QPointer<QObject> exclusiveGrabberContext; // extra info about where the grab happened
60 QList<QPointer <QObject> > passiveGrabbers;
61 QList<QPointer <QObject> > passiveGrabbersContext; // parallel list: extra info about where the grabs happened
62 };
63 EventPointData *queryPointById(int id) const;
64 EventPointData *pointById(int id) const;
65 void removePointById(int id);
66 QObject *firstActiveTarget() const;
67 QWindow *firstActiveWindow() const;
68
69 QObject *firstPointExclusiveGrabber() const;
70 void setExclusiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *exclusiveGrabber);
71 bool removeExclusiveGrabber(const QPointerEvent *event, const QObject *grabber);
72 bool addPassiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *grabber);
73 static bool setPassiveGrabberContext(EventPointData *epd, QObject *grabber, QObject *context);
74 bool removePassiveGrabber(const QPointerEvent *event, const QEventPoint &point, QObject *grabber);
75 void clearPassiveGrabbers(const QPointerEvent *event, const QEventPoint &point);
76 void removeGrabber(QObject *grabber, bool cancel = false);
77
78 using EventPointMap = QVarLengthFlatMap<int, EventPointData, 20>;
79 mutable EventPointMap activePoints;
80
81 QPointingDeviceUniqueId uniqueId;
82 quint32 toolId = 0; // only for Wacom tablets
83 qint8 maximumTouchPoints = 0;
84 qint8 buttonCount = 0;
85 QPointingDevice::PointerType pointerType = QPointingDevice::PointerType::Unknown;
86 bool toolProximity = false; // only for Wacom tablets
87
88 inline static QPointingDevicePrivate *get(QPointingDevice *q)
89 {
90 return static_cast<QPointingDevicePrivate *>(QObjectPrivate::get(q));
91 }
92
93 inline static const QPointingDevicePrivate *get(const QPointingDevice *q)
94 {
95 return static_cast<const QPointingDevicePrivate *>(QObjectPrivate::get(q));
96 }
97
98 static const QPointingDevice *tabletDevice(QInputDevice::DeviceType deviceType,
99 QPointingDevice::PointerType pointerType,
100 QPointingDeviceUniqueId uniqueId);
101
102 static const QPointingDevice *queryTabletDevice(QInputDevice::DeviceType deviceType,
103 QPointingDevice::PointerType pointerType,
104 QPointingDeviceUniqueId uniqueId,
105 QInputDevice::Capabilities capabilities = QInputDevice::Capability::None,
106 qint64 systemId = 0);
107
108 static const QPointingDevice *pointingDeviceById(qint64 systemId);
109};
110
111QT_END_NAMESPACE
112
113#endif // QPOINTINGDEVICE_P_H
Combined button and popup list for selecting options.
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
size_t qHash(QByteArrayView key, size_t seed) noexcept
Definition qhash.cpp:876