diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
| commit | b58ec3b086518da5aa573f99426235854c23e35f (patch) | |
| tree | 861a9935d8f1cdba2fdca546836a351736dbddbf /src/quicktemplates/qquickoverlay.cpp | |
| parent | 4826f86e274f1b29bd769e6790824f9e62a40f62 (diff) | |
| parent | 22032227d16c39211e2ebceef97d21f4d89c7c87 (diff) | |
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'src/quicktemplates/qquickoverlay.cpp')
| -rw-r--r-- | src/quicktemplates/qquickoverlay.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/quicktemplates/qquickoverlay.cpp b/src/quicktemplates/qquickoverlay.cpp index c9d3cf9892..091b2f8fb3 100644 --- a/src/quicktemplates/qquickoverlay.cpp +++ b/src/quicktemplates/qquickoverlay.cpp @@ -97,9 +97,32 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) return false; } +static QQuickItem *findRootOfOverlaySubtree(QQuickItem *source, const QQuickOverlay *overlay) +{ + QQuickItem *sourceAncestor = source; + while (sourceAncestor) { + QQuickItem *parentItem = sourceAncestor->parentItem(); + if (parentItem == overlay) + return sourceAncestor; + sourceAncestor = parentItem; + } + // Not an ancestor of the overlay. + return nullptr; +} + bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target) { + Q_Q(const QQuickOverlay); if (target) { + // childMouseEventFilter will cause this function to get called for each active popup. + // If any of those active popups block inputs, the delivery agent won't send the press event to source. + // A popup will block input, if it's modal, and the item isn't an ancestor of the popup's popup item. + // If source doesn't belong to a popup, but exists in an overlay subtree, it makes sense to not filter the event. + const QList<QQuickItem *> childItems = paintOrderChildItems(); + if (childItems.indexOf(findRootOfOverlaySubtree(source, q)) + > childItems.indexOf(QQuickPopupPrivate::get(target)->popupItem)) + return false; + if (target->overlayEvent(source, event)) { setMouseGrabberPopup(target); return true; @@ -143,7 +166,17 @@ bool QQuickOverlayPrivate::handleMove(QQuickItem *source, QEvent *event, QQuickP bool QQuickOverlayPrivate::handleRelease(QQuickItem *source, QEvent *event, QQuickPopup *target) { + Q_Q(const QQuickOverlay); if (target) { + // childMouseEventFilter will cause this function to get called for each active popup. + // If any of those active popups block inputs, the delivery agent won't send the press event to source. + // A popup will block input, if it's modal, and the item isn't an ancestor of the popup's popup item. + // If source doesn't belong to a popup, but exists in an overlay subtree, it makes sense to not filter the event. + const QList<QQuickItem *> childItems = paintOrderChildItems(); + if (childItems.indexOf(findRootOfOverlaySubtree(source, q)) + > childItems.indexOf(QQuickPopupPrivate::get(target)->popupItem)) + return false; + setMouseGrabberPopup(nullptr); if (target->overlayEvent(source, event)) { setMouseGrabberPopup(nullptr); |
