aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Koivikko <[email protected]>2025-04-30 17:25:36 +0300
committerJarkko Koivikko <[email protected]>2025-05-09 08:44:35 +0300
commit4db78fc04d7f83330990a17f2c58392de6412fb5 (patch)
tree2099fe15b62ac7a2d06cac20b39ea9e9286f47eb
parentfcc1f9c499d024cf4d904067406a716e15b6824d (diff)
qquickpopup: Minimize overlay calls in finalizeExitTransition
Pict-to: 6.9 Change-Id: I4a3147a11d36ed6db94b454581ee4dee0a8730e4 Reviewed-by: Santhosh Kumar <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r--src/quicktemplates/qquickpopup.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/quicktemplates/qquickpopup.cpp b/src/quicktemplates/qquickpopup.cpp
index 78f8802403..42bc092e7a 100644
--- a/src/quicktemplates/qquickpopup.cpp
+++ b/src/quicktemplates/qquickpopup.cpp
@@ -839,11 +839,13 @@ void QQuickPopupPrivate::finalizeExitTransition()
}
destroyDimmer();
- if (hadActiveFocusBeforeExitTransition && window) {
+ if (auto *overlay = QQuickOverlay::overlay(window)) {
+ auto *overlayPrivate = QQuickOverlayPrivate::get(overlay);
+
// restore focus to the next popup in chain, or to the window content if there are no other popups open
- QQuickPopup *nextFocusPopup = nullptr;
- if (QQuickOverlay *overlay = QQuickOverlay::overlay(window)) {
- const auto stackingOrderPopups = QQuickOverlayPrivate::get(overlay)->stackingOrderPopups();
+ if (hadActiveFocusBeforeExitTransition) {
+ QQuickPopup *nextFocusPopup = nullptr;
+ const auto stackingOrderPopups = overlayPrivate->stackingOrderPopups();
for (auto popup : stackingOrderPopups) {
// only pick a popup that is focused but has not already been activated
if (QQuickPopupPrivate::get(popup)->transitionState != ExitTransition
@@ -852,30 +854,24 @@ void QQuickPopupPrivate::finalizeExitTransition()
break;
}
}
- }
- if (nextFocusPopup) {
- nextFocusPopup->forceActiveFocus(Qt::PopupFocusReason);
- } else if (auto *overlay = QQuickOverlay::overlay(window)) {
- auto *appWindow = qobject_cast<QQuickApplicationWindow*>(window);
- auto *contentItem = appWindow ? appWindow->contentItem() : window->contentItem();
- auto *overlayPrivate = QQuickOverlayPrivate::get(overlay);
- if (!contentItem->scopedFocusItem()
- && !overlayPrivate->lastActiveFocusItem.isNull()) {
- // The last active focus item may have lost focus not just for
- // itself but for its entire focus chain, so force active focus.
- overlayPrivate->lastActiveFocusItem->forceActiveFocus(Qt::OtherFocusReason);
+ if (nextFocusPopup) {
+ nextFocusPopup->forceActiveFocus(Qt::PopupFocusReason);
} else {
- contentItem->setFocus(true, Qt::PopupFocusReason);
+ auto *appWindow = qobject_cast<QQuickApplicationWindow*>(window);
+ auto *contentItem = appWindow ? appWindow->contentItem() : window->contentItem();
+ if (!contentItem->scopedFocusItem()
+ && !overlayPrivate->lastActiveFocusItem.isNull()) {
+ // The last active focus item may have lost focus not just for
+ // itself but for its entire focus chain, so force active focus.
+ overlayPrivate->lastActiveFocusItem->forceActiveFocus(Qt::OtherFocusReason);
+ } else {
+ contentItem->setFocus(true, Qt::PopupFocusReason);
+ }
}
}
- }
-
- if (window) {
- auto *overlay = QQuickOverlay::overlay(window);
- auto *overlayPrivate = overlay ? QQuickOverlayPrivate::get(overlay) : nullptr;
// Clear the overlay's saved focus if this popup was the one that set it
- if (savedLastActiveFocusItem && overlayPrivate)
+ if (savedLastActiveFocusItem)
overlayPrivate->lastActiveFocusItem = nullptr;
}