Bug 346301 - "Session restore restores windows in the wrong taskbar order" [p=tbertels@gmail.com (Thomas Bertels) r=zeniko a1.9=mconnor]

This commit is contained in:
reed@reedloden.com 2007-09-29 00:01:39 -07:00
parent df3f2cb363
commit 57e608eb04

View File

@ -78,7 +78,7 @@ const OBSERVING = [
/*
XUL Window properties to (re)store
Restored in restoreDimensions_proxy()
Restored in restoreDimensions()
*/
const WINDOW_ATTRIBUTES = ["width", "height", "screenX", "screenY", "sizemode"];
@ -452,6 +452,10 @@ SessionStoreService.prototype = {
return;
}
if (this.windowToFocus && this.windowToFocus == aWindow) {
delete this.windowToFocus;
}
var tabbrowser = aWindow.getBrowser();
var tabpanels = tabbrowser.mPanelContainer;
@ -1175,18 +1179,16 @@ SessionStoreService.prototype = {
}
this._updateCookies(total);
// make sure that the current window is restored first
var ix = activeWindow ? windows.indexOf(activeWindow.__SSi || "") : -1;
if (ix > 0) {
total.unshift(total.splice(ix, 1)[0]);
}
// if no browser window remains open, return the state of the last closed window
if (total.length == 0 && this._lastWindowClosed) {
total.push(this._lastWindowClosed);
}
return { windows: total };
if (activeWindow) {
this.activeWindowSSiCache = activeWindow.__SSi || "";
}
ix = this.activeWindowSSiCache ? windows.indexOf(this.activeWindowSSiCache) : -1;
return { windows: total, selectedWindow: ix + 1 };
},
/**
@ -1226,8 +1228,13 @@ SessionStoreService.prototype = {
* JS object or its eval'able source
* @param aOverwriteTabs
* bool overwrite existing tabs w/ new ones
* @param aFollowUp
* bool this isn't the restoration of the first window
*/
restoreWindow: function sss_restoreWindow(aWindow, aState, aOverwriteTabs) {
restoreWindow: function sss_restoreWindow(aWindow, aState, aOverwriteTabs, aFollowUp) {
if (!aFollowUp) {
this.windowToFocus = aWindow;
}
// initialize window if necessary
if (aWindow && (!aWindow.__SSi || !this._windows[aWindow.__SSi]))
this.onLoad(aWindow);
@ -1244,15 +1251,20 @@ SessionStoreService.prototype = {
}
var winData;
if (!aState.selectedWindow) {
aState.selectedWindow = 0;
}
// open new windows for all further window entries of a multi-window session
// (unless they don't contain any tab data)
for (var w = 1; w < root.windows.length; w++) {
winData = root.windows[w];
if (winData && winData.tabs && winData.tabs[0]) {
this._openWindowWithState({ windows: [winData], opener: aWindow });
var window = this._openWindowWithState({ windows: [winData] });
if (w == aState.selectedWindow - 1) {
this.windowToFocus = window;
}
}
}
winData = root.windows[0];
if (!winData.tabs) {
winData.tabs = [];
@ -1276,7 +1288,7 @@ SessionStoreService.prototype = {
}
if (aOverwriteTabs) {
this.restoreWindowFeatures(aWindow, winData, root.opener || null);
this.restoreWindowFeatures(aWindow, winData);
}
if (winData.cookies) {
this.restoreCookies(winData.cookies);
@ -1590,10 +1602,8 @@ SessionStoreService.prototype = {
* Window reference
* @param aWinData
* Object containing session data for the window
* @param aOpener
* Opening window, for refocusing
*/
restoreWindowFeatures: function sss_restoreWindowFeatures(aWindow, aWinData, aOpener) {
restoreWindowFeatures: function sss_restoreWindowFeatures(aWindow, aWinData) {
var hidden = (aWinData.hidden)?aWinData.hidden.split(","):[];
WINDOW_HIDEABLE_FEATURES.forEach(function(aItem) {
aWindow[aItem].visible = hidden.indexOf(aItem) == -1;
@ -1601,7 +1611,7 @@ SessionStoreService.prototype = {
var _this = this;
aWindow.setTimeout(function() {
_this.restoreDimensions_proxy.apply(_this, [aWindow, aOpener, aWinData.width || 0,
_this.restoreDimensions.apply(_this, [aWindow, aWinData.width || 0,
aWinData.height || 0, "screenX" in aWinData ? aWinData.screenX : NaN,
"screenY" in aWinData ? aWinData.screenY : NaN,
aWinData.sizemode || "", aWinData.sidebar || ""]);
@ -1610,8 +1620,6 @@ SessionStoreService.prototype = {
/**
* Restore a window's dimensions
* @param aOpener
* Opening window, for refocusing
* @param aWidth
* Window width
* @param aHeight
@ -1625,7 +1633,7 @@ SessionStoreService.prototype = {
* @param aSidebar
* Sidebar command
*/
restoreDimensions_proxy: function sss_restoreDimensions_proxy(aWindow, aOpener, aWidth, aHeight, aLeft, aTop, aSizeMode, aSidebar) {
restoreDimensions: function sss_restoreDimensions(aWindow, aWidth, aHeight, aLeft, aTop, aSizeMode, aSidebar) {
var win = aWindow;
var _this = this;
function win_(aName) { return _this._getWindowDimension(win, aName); }
@ -1648,9 +1656,9 @@ SessionStoreService.prototype = {
aWindow.toggleSidebar(aSidebar);
}
// since resizing/moving a window brings it to the foreground,
// we might want to re-focus the window which created this one
if (aOpener) {
aOpener.focus();
// we might want to re-focus the last focused window
if (this.windowToFocus) {
this.windowToFocus.focus();
}
},
@ -1818,6 +1826,8 @@ SessionStoreService.prototype = {
_this.restoreWindow(aEvent.currentTarget, aEvent.currentTarget.__SS_state, true, true);
delete aEvent.currentTarget.__SS_state;
}, true);
return window;
},
/**