commit c1e6f796d4ea069455b5d9c600187cec12fed553
parent da0847eb0ebeb0784fd2855ecb91b8f1cefdb9ee
Author: Greg Stoll <gstoll@mozilla.com>
Date: Mon, 6 Oct 2025 14:28:56 +0000
Bug 1968297 - ensure windows that are occluded after session restore draw a taskbar preview (again x2) r=win-reviewers,sessionstore-reviewers,handyman,sfoster
The previous patches have made this better, but there's still a problem
if a window gets resized during session restore. (it's easiest to see this
if its natural size is small and then it gets maximized)
There are a number of ways to fix this, but I think delaying the "session
was restored" message until the window is resized makes sense, and that means
we can just extend the check for "should I pretend I'm not occluded" to
include if session restoring is in progress.
Differential Revision: https://phabricator.services.mozilla.com/D267426
Diffstat:
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
@@ -5916,14 +5916,6 @@ var SessionStoreInternal = {
arrowScrollbox.smoothScroll = smoothScroll;
Glean.sessionRestore.restoreWindow.stopAndAccumulate(timerId);
-
- this._setWindowStateReady(aWindow);
-
- this._sendWindowRestoredNotification(aWindow);
-
- Services.obs.notifyObservers(aWindow, NOTIFY_SINGLE_WINDOW_RESTORED);
-
- this._sendRestoreCompletedNotifications();
},
/**
@@ -5986,9 +5978,11 @@ var SessionStoreInternal = {
_restoreWindowsFeaturesAndTabs(windows) {
// First, we restore window features, so that when users start interacting
// with a window, we don't steal the window focus.
+ let resizePromises = [];
for (let window of windows) {
let state = this._statesToRestore[WINDOW_RESTORE_IDS.get(window)];
- this.restoreWindowFeatures(window, state.windows[0]);
+ // Wait for these promises after we've restored data into them below.
+ resizePromises.push(this.restoreWindowFeatures(window, state.windows[0]));
}
// Then we restore data into windows.
@@ -6001,6 +5995,20 @@ var SessionStoreInternal = {
);
WINDOW_RESTORE_ZINDICES.delete(window);
}
+ for (let resizePromise of resizePromises) {
+ resizePromise.then(resizedWindow => {
+ this._setWindowStateReady(resizedWindow);
+
+ this._sendWindowRestoredNotification(resizedWindow);
+
+ Services.obs.notifyObservers(
+ resizedWindow,
+ NOTIFY_SINGLE_WINDOW_RESTORED
+ );
+
+ this._sendRestoreCompletedNotifications();
+ });
+ }
},
/**
@@ -6505,6 +6513,7 @@ var SessionStoreInternal = {
}
}
+ let promiseParts = Promise.withResolvers();
aWindow.setTimeout(() => {
this.restoreDimensions(
aWindow,
@@ -6516,7 +6525,9 @@ var SessionStoreInternal = {
aWinData.sizemodeBeforeMinimized || ""
);
this.restoreSidebar(aWindow, aWinData.sidebar, aWinData.isPopup);
+ promiseParts.resolve(aWindow);
}, 0);
+ return promiseParts.promise;
},
/**
diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp
@@ -317,9 +317,10 @@ void nsWindow::NotifyOcclusionState(mozilla::widget::OcclusionState aState) {
if (mFrameState->GetSizeMode() == nsSizeMode_Minimized) {
isFullyOccluded = false;
}
- if (isFullyOccluded && !mHasBeenShown) {
+ if (isFullyOccluded && (!mHasBeenShown || nsWindow::sIsRestoringSession)) {
// Don't mark a newly-created window as occluded until
- // it renders a taskbar icon. (bug 1968297)
+ // it is finished being restored (including sizing) and has been shown once.
+ // (bug 1968297)
isFullyOccluded = false;
}