mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 669272 - Minimize window movement when restoring session; r=zpao
This commit is contained in:
parent
bb7126dc8c
commit
1bda5bc365
@ -486,6 +486,11 @@ SessionStoreService.prototype = {
|
||||
this._forEachBrowserWindow(function(aWindow) {
|
||||
this._collectWindowData(aWindow);
|
||||
});
|
||||
// we must cache this because _getMostRecentBrowserWindow will always
|
||||
// return null by the time quit-application occurs
|
||||
var activeWindow = this._getMostRecentBrowserWindow();
|
||||
if (activeWindow)
|
||||
this.activeWindowSSiCache = activeWindow.__SSi || "";
|
||||
this._dirtyWindows = [];
|
||||
break;
|
||||
case "quit-application-granted":
|
||||
@ -1512,6 +1517,13 @@ SessionStoreService.prototype = {
|
||||
let lastWindow = this._getMostRecentBrowserWindow();
|
||||
let canUseLastWindow = lastWindow &&
|
||||
!lastWindow.__SS_lastSessionWindowID;
|
||||
let lastSessionFocusedWindow = null;
|
||||
this.windowToFocus = lastWindow;
|
||||
|
||||
// move the last focused window to the start of the array so that we
|
||||
// minimize window movement (see bug 669272)
|
||||
lastSessionState.windows.unshift(
|
||||
lastSessionState.windows.splice(lastSessionState.selectedWindow - 1, 1)[0]);
|
||||
|
||||
// Restore into windows or open new ones as needed.
|
||||
for (let i = 0; i < lastSessionState.windows.length; i++) {
|
||||
@ -1549,9 +1561,18 @@ SessionStoreService.prototype = {
|
||||
// weirdness but we will still merge other extData.
|
||||
// Bug 588217 should make this go away by merging the group data.
|
||||
this.restoreWindow(windowToUse, { windows: [winState] }, canOverwriteTabs, true);
|
||||
if (i == 0)
|
||||
lastSessionFocusedWindow = windowToUse;
|
||||
|
||||
// if we overwrote the tabs for our last focused window, we should
|
||||
// give focus to the window that had it in the previous session
|
||||
if (canOverwriteTabs && windowToUse == lastWindow)
|
||||
this.windowToFocus = lastSessionFocusedWindow;
|
||||
}
|
||||
else {
|
||||
this._openWindowWithState({ windows: [winState] });
|
||||
let win = this._openWindowWithState({ windows: [winState] });
|
||||
if (i == 0)
|
||||
lastSessionFocusedWindow = win;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2544,8 +2565,12 @@ SessionStoreService.prototype = {
|
||||
this._closedWindows = root._closedWindows;
|
||||
|
||||
var winData;
|
||||
if (!aState.selectedWindow) {
|
||||
aState.selectedWindow = 0;
|
||||
if (!root.selectedWindow) {
|
||||
root.selectedWindow = 0;
|
||||
} else {
|
||||
// put the selected window at the beginning of the array to ensure that
|
||||
// it gets restored first
|
||||
root.windows.unshift(root.windows.splice(root.selectedWindow - 1, 1)[0]);
|
||||
}
|
||||
// open new windows for all further window entries of a multi-window session
|
||||
// (unless they don't contain any tab data)
|
||||
@ -2553,9 +2578,6 @@ SessionStoreService.prototype = {
|
||||
winData = root.windows[w];
|
||||
if (winData && winData.tabs && winData.tabs[0]) {
|
||||
var window = this._openWindowWithState({ windows: [winData] });
|
||||
if (w == aState.selectedWindow - 1) {
|
||||
this.windowToFocus = window;
|
||||
}
|
||||
}
|
||||
}
|
||||
winData = root.windows[0];
|
||||
|
Loading…
Reference in New Issue
Block a user