diff options
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); |
