Coverage Report

Created: 2026-03-12 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qpointingdevice_p.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_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
28
QT_BEGIN_NAMESPACE
29
30
Q_DECLARE_LOGGING_CATEGORY(lcPointerGrab);
31
32
class Q_GUI_EXPORT QPointingDevicePrivate : public QInputDevicePrivate
33
{
34
0
    Q_DECLARE_PUBLIC(QPointingDevice)
Unexecuted instantiation: QPointingDevicePrivate::q_func()
Unexecuted instantiation: QPointingDevicePrivate::q_func() const
35
0
public:
36
0
    QPointingDevicePrivate(const QString &name, qint64 id, QInputDevice::DeviceType type,
37
0
                           QPointingDevice::PointerType pType, QPointingDevice::Capabilities caps,
38
0
                           int maxPoints, int buttonCount,
39
0
                           const QString &seatName = QString(),
40
0
                           QPointingDeviceUniqueId uniqueId = QPointingDeviceUniqueId())
41
0
      : QInputDevicePrivate(name, id, type, caps, seatName),
42
0
        uniqueId(uniqueId),
43
0
        maximumTouchPoints(qint8(maxPoints)), buttonCount(qint8(buttonCount)),
44
0
        pointerType(pType)
45
0
    {
46
0
        pointingDeviceType = true;
47
0
        activePoints.reserve(maxPoints);
48
0
    }
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
0
    {
90
0
        return static_cast<QPointingDevicePrivate *>(QObjectPrivate::get(q));
91
0
    }
92
93
    inline static const QPointingDevicePrivate *get(const QPointingDevice *q)
94
0
    {
95
0
        return static_cast<const QPointingDevicePrivate *>(QObjectPrivate::get(q));
96
0
    }
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
111
QT_END_NAMESPACE
112
113
#endif // QPOINTINGDEVICE_P_H