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 struct HoverItemState {
89 QPointer<QQuickItem> item;
92 using HoverItems = QList<HoverItemState>;
93 HoverItems hoverItems;
94 QList<QQuickItem *> hasFiltered;
95 QList<QQuickItem *> skipDelivery;
97 std::unique_ptr<QMutableTouchEvent> delayedTouch;
98 QList<
const QPointingDevice *> knownPointingDevices;
100 uint currentHoverId = 0;
101#if QT_CONFIG(wheelevent)
102 uint lastWheelEventAccepted = 0;
104 uchar compressedTouchCount = 0;
105 bool allowChildEventFiltering =
true;
106 bool hoveredLeafItemFound =
false;
108 bool isSubsceneAgent =
false;
109 static bool subsceneAgentsExist;
111 static QQuickDeliveryAgent *currentEventDeliveryAgent;
112 static QQuickDeliveryAgent *currentOrItemDeliveryAgent(
const QQuickItem *item);
113 inline static quint64 frameSynchronousHover_counter = 0;
115 int frameSynchronousHoverInterval = 100;
116 QElapsedTimer frameSynchronousHoverTimer;
117 QBasicTimer frameSynchronousDelayTimer;
119 Qt::FocusReason lastFocusReason = Qt::OtherFocusReason;
120 int pointerEventRecursionGuard = 0;
122 int touchMouseId = -1;
124 const QPointingDevice *touchMouseDevice =
nullptr;
125 ulong touchMousePressTimestamp = 0;
126 QPoint touchMousePressPos;
128 QQuickDeliveryAgent::Transform *sceneTransform =
nullptr;
130 bool isDeliveringTouchAsMouse()
const {
return touchMouseId != -1 && touchMouseDevice; }
131 void cancelTouchMouseSynthesis();
133 bool checkIfDoubleTapped(ulong newPressEventTimestamp,
const QPoint &newPressPos);
134 void resetIfDoubleTapPrevented(
const QEventPoint &pressedPoint);
135 QPointingDevicePrivate::EventPointData *mousePointData();
136 QPointerEvent *eventInDelivery()
const;
139 QPointF lastMousePosition;
140 bool deliverTouchAsMouse(QQuickItem *item, QTouchEvent *pointerEvent);
141 static void translateTouchEvent(QTouchEvent *touchEvent);
142 void removeGrabber(QQuickItem *grabber,
bool mouse =
true,
bool touch =
true,
bool cancel =
false);
143 void clearGrabbers(QPointerEvent *pointerEvent);
144 void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition,
const QPointerEvent *event,
const QEventPoint &point);
145 static QPointerEvent *clonePointerEvent(QPointerEvent *event, std::optional<QPointF> transformedLocalPos = std::nullopt);
146 void deliverToPassiveGrabbers(
const QList<QPointer<QObject> > &passiveGrabbers, QPointerEvent *pointerEvent);
147 bool sendFilteredMouseEvent(QEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
148 bool sendFilteredPointerEvent(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent =
nullptr);
149 bool sendFilteredPointerEventImpl(QPointerEvent *event, QQuickItem *receiver, QQuickItem *filteringParent);
150 bool deliverSinglePointEventUntilAccepted(QPointerEvent *);
153 void handleTouchEvent(QTouchEvent *);
154 void handleMouseEvent(QMouseEvent *);
155 bool compressTouchEvent(QTouchEvent *);
156 void flushFrameSynchronousEvents(QQuickWindow *win);
157 void deliverDelayedTouchEvent();
158 void handleWindowDeactivate(QQuickWindow *win);
159 void handleWindowHidden(QQuickWindow *win);
162 bool allUpdatedPointsAccepted(
const QPointerEvent *ev);
163 static void localizePointerEvent(QPointerEvent *ev,
const QQuickItem *dest);
164 QList<QObject *> exclusiveGrabbers(QPointerEvent *ev);
165 static bool anyPointGrabbed(
const QPointerEvent *ev);
166 static bool allPointsGrabbed(
const QPointerEvent *ev);
167 static bool isMouseEvent(
const QPointerEvent *ev);
168 static bool isMouseOrWheelEvent(
const QPointerEvent *ev);
169 static bool isHoverEvent(
const QPointerEvent *ev);
170 static bool isHoveringMoveEvent(
const QPointerEvent *ev);
171 static bool isTouchEvent(
const QPointerEvent *ev);
172 static bool isTabletEvent(
const QPointerEvent *ev);
173 static bool isEventFromMouseOrTouchpad(
const QPointerEvent *ev);
174 static bool isSynthMouse(
const QPointerEvent *ev);
175 static bool isWithinDoubleClickInterval(ulong timeInterval);
176 static bool isWithinDoubleTapDistance(
const QPoint &distanceBetweenPresses);
177 static bool isSinglePointDevice(
const QInputDevice *dev);
178 static QQuickPointingDeviceExtra *deviceExtra(
const QInputDevice *device);
181 void touchToMouseEvent(QEvent::Type type,
const QEventPoint &p,
const QTouchEvent *touchEvent, QMutableSinglePointEvent *mouseEvent);
182 void ensureDeviceConnected(
const QPointingDevice *dev);
183 void deliverPointerEvent(QPointerEvent *);
184 bool deliverTouchCancelEvent(QTouchEvent *);
185 bool deliverPressOrReleaseEvent(QPointerEvent *,
bool handlersOnly =
false);
186 void deliverUpdatedPoints(QPointerEvent *event);
187 void deliverMatchingPointsToItem(QQuickItem *item,
bool isGrabber, QPointerEvent *pointerEvent,
bool handlersOnly =
false);
189 QList<QQuickItem *> eventTargets(QQuickItem *,
const QEvent *event,
int pointId, QPointF localPos, QPointF scenePos,
190 qxp::function_ref<std::optional<
bool> (QQuickItem *,
const QEvent *)> predicate)
const;
191 QList<QQuickItem *> pointerTargets(QQuickItem *,
const QPointerEvent *event,
const QEventPoint &point,
192 bool checkMouseButtons,
bool checkAcceptsTouch)
const;
193 QList<QQuickItem *> mergePointerTargets(
const QList<QQuickItem *> &list1,
const QList<QQuickItem *> &list2)
const;
196 enum class HoverChange : uint8_t {
200 bool deliverHoverEvent(
const QPointF &scenePos,
const QPointF &lastScenePos, Qt::KeyboardModifiers modifiers, ulong timestamp);
201 bool deliverHoverEventRecursive(QQuickItem *,
const QPointF &localPos,
202 const QPointF &scenePos,
const QPointF &lastScenePos,
203 const QPointF &globalPos, Qt::KeyboardModifiers modifiers, ulong timestamp);
204 bool deliverHoverEventToItem(QQuickItem *item,
const QPointF &localPos,
const QPointF &scenePos,
205 const QPointF &lastScenePos,
const QPointF &globalPos,
206 Qt::KeyboardModifiers modifiers, ulong timestamp,
207 HoverChange hoverChange);
208 bool sendHoverEvent(QEvent::Type, QQuickItem *,
const QPointF &localPos,
const QPointF &scenePos,
209 const QPointF &lastScenePos,
const QPointF &globalPos,
210 Qt::KeyboardModifiers modifiers, ulong timestamp);
211 bool clearHover(ulong timestamp = 0);
213#if QT_CONFIG(quick_draganddrop)
214 void deliverDragEvent(QQuickDragGrabber *, QEvent *);
215 bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *,
216 QVarLengthArray<QQuickItem *, 64> *currentGrabItems =
nullptr,
217 QObject *formerTarget =
nullptr);
220 static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event,
int startDragThreshold = -1);
222 static bool dragOverThreshold(qreal d, Qt::Axis axis,
const QEventPoint &tp,
int startDragThreshold = -1);
224 static bool dragOverThreshold(QVector2D delta);
227 QList<QQuickItem *> contextMenuTargets(QQuickItem *item,
const QContextMenuEvent *event)
const;
228 void deliverContextMenuEvent(QContextMenuEvent *event);