58 Q_DECLARE_PUBLIC(QQuickDeliveryAgent)
59 QQuickDeliveryAgentPrivate(QQuickItem *root);
60 ~QQuickDeliveryAgentPrivate();
62 QQuickItem *rootItem =
nullptr;
64 QQuickItem *activeFocusItem =
nullptr;
66 void deliverKeyEvent(QKeyEvent *e);
69 DontChangeFocusProperty = 0x01,
70 DontChangeSubFocusItem = 0x02
72 Q_DECLARE_FLAGS(FocusOptions, FocusOption)
74 void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { });
75 void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = { });
76 static void notifyFocusChangesRecur(QQuickItem **item,
int remaining, Qt::FocusReason reason);
77 void clearFocusObject();
78 void updateFocusItemTransform();
80 QQuickItem *focusTargetItem()
const;
83#if QT_CONFIG(quick_draganddrop)
84 QQuickDragGrabber *dragGrabber =
nullptr;
86 QQuickItem *lastUngrabbed =
nullptr;
87 QStack<QPointerEvent *> eventsInDelivery;
88 QFlatMap<QPointer<QQuickItem>, uint> hoverItems;
89 QList<QQuickItem *> hasFiltered;
90 QList<QQuickItem *> skipDelivery;
92 std::unique_ptr<QMutableTouchEvent> delayedTouch;
93 QList<
const QPointingDevice *> knownPointingDevices;
95 uint currentHoverId = 0;
96#if QT_CONFIG(wheelevent)
97 uint lastWheelEventAccepted = 0;
99 uchar compressedTouchCount = 0;
100 bool allowChildEventFiltering =
true;
101 bool hoveredLeafItemFound =
false;
103 bool isSubsceneAgent =
false;
104 static bool subsceneAgentsExist;
106 static QQuickDeliveryAgent *currentEventDeliveryAgent;
107 static QQuickDeliveryAgent *currentOrItemDeliveryAgent(
const QQuickItem *item);
108 inline static quint64 frameSynchronousHover_counter = 0;
110 int frameSynchronousHoverInterval = 100;
111 QElapsedTimer frameSynchronousHoverTimer;
112 QBasicTimer frameSynchronousDelayTimer;
114 Qt::FocusReason lastFocusReason = Qt::OtherFocusReason;
115 int pointerEventRecursionGuard = 0;
117 int touchMouseId = -1;
119 const QPointingDevice *touchMouseDevice =
nullptr;
120 ulong touchMousePressTimestamp = 0;
121 QPoint touchMousePressPos;
123 QQuickDeliveryAgent::Transform *sceneTransform =
nullptr;
125 bool isDeliveringTouchAsMouse()
const {
return touchMouseId != -1 && touchMouseDevice; }
126 void cancelTouchMouseSynthesis();
128 bool checkIfDoubleTapped(ulong newPressEventTimestamp,
const QPoint &newPressPos);
129 void resetIfDoubleTapPrevented(
const QEventPoint &pressedPoint);
130 QPointingDevicePrivate::EventPointData *mousePointData();
131 QPointerEvent *eventInDelivery()
const;
134 QPointF lastMousePosition;
135 bool deliverTouchAsMouse(QQuickItem *item, QTouchEvent *pointerEvent);
136 static void translateTouchEvent(QTouchEvent *touchEvent);
137 void removeGrabber(QQuickItem *grabber,
bool mouse =
true,
bool touch =
true,
bool cancel =
false);
138 void clearGrabbers(QPointerEvent *pointerEvent);
139 void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition,
const QPointerEvent *event,
const QEventPoint &point);
140 static QPointerEvent *clonePointerEvent(QPointerEvent *event, std::optional<QPointF> transformedLocalPos = std::nullopt);
141 void deliverToPassiveGrabbers(
const QList<QPointer<QObject> > &passiveGrabbers, QPointerEvent *pointerEvent);
142 bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
143 bool sendFilteredPointerEvent(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent =
nullptr);
144 bool sendFilteredPointerEventImpl(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
145 bool deliverSinglePointEventUntilAccepted(QPointerEvent *);
148 void handleTouchEvent(QTouchEvent *);
149 void handleMouseEvent(QMouseEvent *);
150 bool compressTouchEvent(QTouchEvent *);
151 void flushFrameSynchronousEvents(QQuickWindow *win);
152 void deliverDelayedTouchEvent();
153 void handleWindowDeactivate(QQuickWindow *win);
154 void handleWindowHidden(QQuickWindow *win);
157 bool allUpdatedPointsAccepted(
const QPointerEvent *ev);
158 static void localizePointerEvent(QPointerEvent *ev,
const QQuickItem *dest);
159 QList<QObject *> exclusiveGrabbers(QPointerEvent *ev);
160 static bool anyPointGrabbed(
const QPointerEvent *ev);
161 static bool allPointsGrabbed(
const QPointerEvent *ev);
162 static bool isMouseEvent(
const QPointerEvent *ev);
163 static bool isMouseOrWheelEvent(
const QPointerEvent *ev);
164 static bool isHoverEvent(
const QPointerEvent *ev);
165 static bool isHoveringMoveEvent(
const QPointerEvent *ev);
166 static bool isTouchEvent(
const QPointerEvent *ev);
167 static bool isTabletEvent(
const QPointerEvent *ev);
168 static bool isEventFromMouseOrTouchpad(
const QPointerEvent *ev);
169 static bool isSynthMouse(
const QPointerEvent *ev);
170 static bool isWithinDoubleClickInterval(ulong timeInterval);
171 static bool isWithinDoubleTapDistance(
const QPoint &distanceBetweenPresses);
172 static bool isSinglePointDevice(
const QInputDevice *dev);
173 static QQuickPointingDeviceExtra *deviceExtra(
const QInputDevice *device);
176 void touchToMouseEvent(QEvent::Type type,
const QEventPoint &p,
const QTouchEvent *touchEvent, QMutableSinglePointEvent *mouseEvent);
177 void ensureDeviceConnected(
const QPointingDevice *dev);
178 void deliverPointerEvent(QPointerEvent *);
179 bool deliverTouchCancelEvent(QTouchEvent *);
180 bool deliverPressOrReleaseEvent(QPointerEvent *,
bool handlersOnly =
false);
181 void deliverUpdatedPoints(QPointerEvent *event);
182 void deliverMatchingPointsToItem(QQuickItem *item,
bool isGrabber, QPointerEvent *pointerEvent,
bool handlersOnly =
false);
184 QList<QQuickItem *> eventTargets(QQuickItem *,
const QEvent *event,
int pointId, QPointF localPos, QPointF scenePos,
185 qxp::function_ref<std::optional<
bool> (QQuickItem *,
const QEvent *)> predicate)
const;
186 QList<QQuickItem *> pointerTargets(QQuickItem *,
const QPointerEvent *event,
const QEventPoint &point,
187 bool checkMouseButtons,
bool checkAcceptsTouch)
const;
188 QList<QQuickItem *> mergePointerTargets(
const QList<QQuickItem *> &list1,
const QList<QQuickItem *> &list2)
const;
191 enum class HoverChange : uint8_t {
195 bool deliverHoverEvent(
const QPointF &scenePos,
const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp);
196 bool deliverHoverEventRecursive(QQuickItem *,
const QPointF &localPos,
197 const QPointF &scenePos,
const QPointF &lastScenePos,
198 const QPointF &globalPos, Qt::KeyboardModifiers modifiers, ulong timestamp);
199 bool deliverHoverEventToItem(QQuickItem *item,
const QPointF &localPos,
const QPointF &scenePos,
200 const QPointF &lastScenePos,
const QPointF &globalPos,
201 Qt::KeyboardModifiers modifiers, ulong timestamp,
202 HoverChange hoverChange);
203 bool sendHoverEvent(QEvent::Type, QQuickItem *,
const QPointF &localPos,
const QPointF &scenePos,
204 const QPointF &lastScenePos,
const QPointF &globalPos,
205 Qt::KeyboardModifiers modifiers, ulong timestamp);
206 bool clearHover(ulong timestamp = 0);
208#if QT_CONFIG(quick_draganddrop)
209 void deliverDragEvent(QQuickDragGrabber *, QEvent *);
210 bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *,
211 QVarLengthArray<QQuickItem *, 64> *currentGrabItems =
nullptr,
212 QObject *formerTarget =
nullptr);
215 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event,
int startDragThreshold = -1);
217 static bool dragOverThreshold(qreal d, Qt::Axis axis,
const QEventPoint &tp,
int startDragThreshold = -1);
219 static bool dragOverThreshold(QVector2D delta);
222 QList<QQuickItem *> contextMenuTargets(QQuickItem *item,
const QContextMenuEvent *event)
const;
223 void deliverContextMenuEvent(QContextMenuEvent *event);