Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickdeliveryagent_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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
4#ifndef QQUICKDELIVERYAGENT_P_P_H
5#define QQUICKDELIVERYAGENT_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qquickdeliveryagent_p.h>
19#include <QtGui/qevent.h>
20#include <QtCore/qstack.h>
21
22#include <private/qevent_p.h>
23#include <private/qpointingdevice_p.h>
24
25#include <QtCore/qpointer.h>
26#include <private/qobject_p.h>
27
28#include <memory>
29
31
33class QQuickItem;
35class QQuickWindow;
36
41 // used in QQuickPointerHandlerPrivate::deviceDeliveryTargets
42 QVector<QObject *> deliveryTargets;
43};
44
45class Q_QUICK_EXPORT QQuickDeliveryAgentPrivate : public QObjectPrivate
46{
47public:
48 Q_DECLARE_PUBLIC(QQuickDeliveryAgent)
51
52 QQuickItem *rootItem = nullptr;
53
54 QQuickItem *activeFocusItem = nullptr;
55
56 void deliverKeyEvent(QKeyEvent *e);
57
59 DontChangeFocusProperty = 0x01,
60 DontChangeSubFocusItem = 0x02
61 };
62 Q_DECLARE_FLAGS(FocusOptions, FocusOption)
63
64 void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { });
65 void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { });
66 static void notifyFocusChangesRecur(QQuickItem **item, int remaining, Qt::FocusReason reason);
67 void clearFocusObject();
68 void updateFocusItemTransform();
69
70 QQuickItem *focusTargetItem() const;
71
72 // Keeps track of the item currently receiving mouse events
73#if QT_CONFIG(quick_draganddrop)
74 QQuickDragGrabber *dragGrabber = nullptr;
75#endif
76 QQuickItem *lastUngrabbed = nullptr;
77 QStack<QPointerEvent *> eventsInDelivery;
78 QFlatMap<QPointer<QQuickItem>, uint> hoverItems;
79 QVector<QQuickItem *> hasFiltered; // during event delivery to a single receiver, the filtering parents for which childMouseEventFilter was already called
80 QVector<QQuickItem *> skipDelivery; // during delivery of one event to all receivers, Items to which we know delivery is no longer necessary
81
82 std::unique_ptr<QMutableTouchEvent> delayedTouch;
83 QList<const QPointingDevice *> knownPointingDevices;
84
85 uint currentHoverId = 0;
86#if QT_CONFIG(wheelevent)
87 uint lastWheelEventAccepted = 0;
88#endif
89 uchar compressedTouchCount = 0;
90 bool allowChildEventFiltering = true;
91 bool frameSynchronousHoverEnabled = true;
92 bool hoveredLeafItemFound = false;
93
94 bool isSubsceneAgent = false;
96 // QQuickDeliveryAgent::event() sets this to the one that's currently (trying to) handle the event
98 static QQuickDeliveryAgent *currentOrItemDeliveryAgent(const QQuickItem *item);
99
101 int pointerEventRecursionGuard = 0;
102
103 int touchMouseId = -1; // only for obsolete stuff like QQuickItem::grabMouse()
104 // TODO get rid of these
105 const QPointingDevice *touchMouseDevice = nullptr;
106 ulong touchMousePressTimestamp = 0;
107 QPoint touchMousePressPos; // in screen coordinates
108
110
111 bool isDeliveringTouchAsMouse() const { return touchMouseId != -1 && touchMouseDevice; }
112 void cancelTouchMouseSynthesis();
113
114 bool checkIfDoubleTapped(ulong newPressEventTimestamp, QPoint newPressPos);
116 QPointerEvent *eventInDelivery() const;
117
118 // Mouse positions are saved in widget coordinates
120 bool deliverTouchAsMouse(QQuickItem *item, QTouchEvent *pointerEvent);
121 void translateTouchEvent(QTouchEvent *touchEvent);
122 void removeGrabber(QQuickItem *grabber, bool mouse = true, bool touch = true, bool cancel = false);
123 void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point);
124 static QPointerEvent *clonePointerEvent(QPointerEvent *event, std::optional<QPointF> transformedLocalPos = std::nullopt);
125 void deliverToPassiveGrabbers(const QVector<QPointer<QObject> > &passiveGrabbers, QPointerEvent *pointerEvent);
126 bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
127 bool sendFilteredPointerEvent(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent = nullptr);
128 bool sendFilteredPointerEventImpl(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
129 bool deliverSinglePointEventUntilAccepted(QPointerEvent *);
130
131 // entry point of events to the window
132 void handleTouchEvent(QTouchEvent *);
133 void handleMouseEvent(QMouseEvent *);
134 bool compressTouchEvent(QTouchEvent *);
135 void flushFrameSynchronousEvents(QQuickWindow *win);
136 void deliverDelayedTouchEvent();
137 void handleWindowDeactivate(QQuickWindow *win);
138 void handleWindowHidden(QQuickWindow *win);
139
140 // utility functions that used to be in QQuickPointerEvent et al.
141 bool allUpdatedPointsAccepted(const QPointerEvent *ev);
142 static void localizePointerEvent(QPointerEvent *ev, const QQuickItem *dest);
143 QList<QObject *> exclusiveGrabbers(QPointerEvent *ev);
144 static bool anyPointGrabbed(const QPointerEvent *ev);
145 static bool allPointsGrabbed(const QPointerEvent *ev);
146 static bool isMouseEvent(const QPointerEvent *ev);
147 static bool isMouseOrWheelEvent(const QPointerEvent *ev);
148 static bool isHoverEvent(const QPointerEvent *ev);
149 static bool isTouchEvent(const QPointerEvent *ev);
150 static bool isTabletEvent(const QPointerEvent *ev);
151 static bool isEventFromMouseOrTouchpad(const QPointerEvent *ev);
152 static bool isSynthMouse(const QPointerEvent *ev);
153 static QQuickPointingDeviceExtra *deviceExtra(const QInputDevice *device);
154
155 // delivery of pointer events:
156 void touchToMouseEvent(QEvent::Type type, const QEventPoint &p, const QTouchEvent *touchEvent, QMutableSinglePointEvent *mouseEvent);
157 void ensureDeviceConnected(const QPointingDevice *dev);
158 void deliverPointerEvent(QPointerEvent *);
159 bool deliverTouchCancelEvent(QTouchEvent *);
160 bool deliverPressOrReleaseEvent(QPointerEvent *, bool handlersOnly = false);
161 void deliverUpdatedPoints(QPointerEvent *event);
162 void deliverMatchingPointsToItem(QQuickItem *item, bool isGrabber, QPointerEvent *pointerEvent, bool handlersOnly = false);
163
164 QVector<QQuickItem *> pointerTargets(QQuickItem *, const QPointerEvent *event, const QEventPoint &point,
165 bool checkMouseButtons, bool checkAcceptsTouch) const;
166 QVector<QQuickItem *> mergePointerTargets(const QVector<QQuickItem *> &list1, const QVector<QQuickItem *> &list2) const;
167
168 // hover delivery
169 enum class HoverChange : uint8_t {
170 Clear,
171 Set,
172 };
173 bool deliverHoverEvent(const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp);
174 bool deliverHoverEventRecursive(QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp);
175 bool deliverHoverEventToItem(QQuickItem *item, const QPointF &scenePos, const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp,
176 HoverChange hoverChange);
177 bool sendHoverEvent(QEvent::Type, QQuickItem *, const QPointF &scenePos, const QPointF &lastScenePos,
178 Qt::KeyboardModifiers modifiers, ulong timestamp);
179 bool clearHover(ulong timestamp = 0);
180
181#if QT_CONFIG(quick_draganddrop)
182 void deliverDragEvent(QQuickDragGrabber *, QEvent *);
183 bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *,
184 QVarLengthArray<QQuickItem *, 64> *currentGrabItems = nullptr,
185 QObject *formerTarget = nullptr);
186#endif
187
188 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1);
189
190 static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint &tp, int startDragThreshold = -1);
191
192 static bool dragOverThreshold(QVector2D delta);
193};
194
195Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickDeliveryAgentPrivate::FocusOptions)
196
198
199#endif // QQUICKDELIVERYAGENT_P_P_H
IOBluetoothDevice * device
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
The QInputDevice class describes a device from which a QInputEvent originates.
The QKeyEvent class describes a key event.
Definition qevent.h:424
Definition qlist.h:75
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
A base class for pointer events.
Definition qevent.h:73
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
QFlatMap< QPointer< QQuickItem >, uint > hoverItems
QStack< QPointerEvent * > eventsInDelivery
QList< const QPointingDevice * > knownPointingDevices
QVector< QQuickItem * > hasFiltered
std::unique_ptr< QMutableTouchEvent > delayedTouch
static QQuickDeliveryAgent * currentEventDeliveryAgent
QVector< QQuickItem * > skipDelivery
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
FocusReason
@ OtherFocusReason
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
static bool isMouseEvent(NSEvent *ev)
Definition qnswindow.mm:19
GLenum type
struct _cl_event * event
GLfloat GLfloat p
[1]
const QQuickItem * rootItem(const I &item)
unsigned char uchar
Definition qtypes.h:32
unsigned long ulong
Definition qtypes.h:35
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QWidget * win
Definition settings.cpp:6
future cancel()
rect sceneTransform().map(QPointF(0
QGraphicsItem * item
QVector< QObject * > deliveryTargets