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
qeventpoint_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 QEVENTPOINT_P_H
6#define QEVENTPOINT_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 for the convenience
13// of other Qt classes. 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/qevent.h>
21
22#include <QtCore/qloggingcategory.h>
23#include <QtCore/qpointer.h>
24
26
27Q_DECLARE_LOGGING_CATEGORY(lcPointerVel);
29
30class QPointingDevice;
31
33{
34public:
35 QEventPointPrivate(int id, const QPointingDevice *device)
36 : device(device), pointId(id) { }
37
38 QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
40 {
41 if (state == QEventPoint::State::Released)
42 pressure = 0;
43 }
44 inline bool operator==(const QEventPointPrivate &other) const
45 {
46 return device == other.device
47 && window == other.window
48 && target == other.target
49 && pos == other.pos
50 && scenePos == other.scenePos
51 && globalPos == other.globalPos
52 && globalPressPos == other.globalPressPos
53 && globalGrabPos == other.globalGrabPos
54 && globalLastPos == other.globalLastPos
55 && pressure == other.pressure
56 && rotation == other.rotation
57 && ellipseDiameters == other.ellipseDiameters
58 && velocity == other.velocity
59 && timestamp == other.timestamp
60 && lastTimestamp == other.lastTimestamp
61 && pressTimestamp == other.pressTimestamp
62 && uniqueId == other.uniqueId
63 && pointId == other.pointId
64 && state == other.state;
65 }
66
67 const QPointingDevice *device = nullptr;
80 int pointId = -1;
82 bool accept = false;
83};
84
85// Private subclasses to allow accessing and modifying protected variables.
86// These should NOT hold any extra state.
87
89{
90public:
91 static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state,
92 QPointF position, QPointF scenePosition, QPointF globalPosition)
93 {
94 QEventPoint p(pointId, state, scenePosition, globalPosition);
95 p.d->timestamp = timestamp;
96 p.d->pos = position;
97 return p;
98 }
99
100 static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to);
101
102 static Q_GUI_EXPORT void detach(QEventPoint &p);
103
104#define TRIVIAL_SETTER(type, field, Field)
105 static void set##Field (QEventPoint &p, type arg) { p.d->field = std::move(arg); }
106 /* end */
107
108 TRIVIAL_SETTER(int, pointId, Id)
109 TRIVIAL_SETTER(const QPointingDevice *, device, Device)
110
111 // not trivial:
112 static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t);
113
114 TRIVIAL_SETTER(ulong, pressTimestamp, PressTimestamp)
115 TRIVIAL_SETTER(QEventPoint::State, state, State)
116 TRIVIAL_SETTER(QPointingDeviceUniqueId, uniqueId, UniqueId)
117 TRIVIAL_SETTER(QPointF, pos, Position)
118 TRIVIAL_SETTER(QPointF, scenePos, ScenePosition)
119 TRIVIAL_SETTER(QPointF, globalPos, GlobalPosition)
120
121 TRIVIAL_SETTER(QPointF, globalPressPos, GlobalPressPosition)
122 TRIVIAL_SETTER(QPointF, globalGrabPos, GlobalGrabPosition)
123 TRIVIAL_SETTER(QPointF, globalLastPos, GlobalLastPosition)
124 TRIVIAL_SETTER(QSizeF, ellipseDiameters, EllipseDiameters)
125 TRIVIAL_SETTER(qreal, pressure, Pressure)
126 TRIVIAL_SETTER(qreal, rotation, Rotation)
127 TRIVIAL_SETTER(QVector2D, velocity, Velocity)
128
129 static QWindow *window(const QEventPoint &p) { return p.d->window.data(); }
130
131 TRIVIAL_SETTER(QWindow *, window, Window)
132
133 static QObject *target(const QEventPoint &p) { return p.d->target.data(); }
134
135 TRIVIAL_SETTER(QObject *, target, Target)
136
137#undef TRIVIAL_SETTER
138};
139
140QT_END_NAMESPACE
141
142#endif // QEVENTPOINT_P_H
QEventPointPrivate(int id, const QPointingDevice *device)
QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
QPointer< QObject > target
QEventPoint::State state
QPointer< QWindow > window
QPointingDeviceUniqueId uniqueId
const QPointingDevice * device
bool operator==(const QEventPointPrivate &other) const
static Q_GUI_EXPORT void detach(QEventPoint &p)
static QObject * target(const QEventPoint &p)
static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to)
static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state, QPointF position, QPointF scenePosition, QPointF globalPosition)
static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t)
static QWindow * window(const QEventPoint &p)
Combined button and popup list for selecting options.
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
#define TRIVIAL_SETTER(type, field, Field)
Q_DECLARE_LOGGING_CATEGORY(lcEPDetach)
size_t qHash(QByteArrayView key, size_t seed) noexcept
Definition qhash.cpp:876