mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-29 11:51:51 +00:00
feat: Wait a delay to collapse pinned tabs on startup and listen for space changes on session store, b=no-bug, c=workspaces
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf297aae78c6 100644
|
||||
index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..41bddb36fef7bb74212c261f1c07e40b30ab5f08 100644
|
||||
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
@@ -127,6 +127,8 @@ const TAB_EVENTS = [
|
||||
@@ -127,6 +127,9 @@ const TAB_EVENTS = [
|
||||
"TabGroupCollapse",
|
||||
"TabGroupExpand",
|
||||
"TabSplitViewActivate",
|
||||
+ "TabAddedToEssentials",
|
||||
+ "TabRemovedFromEssentials",
|
||||
+ "ZenWorkspaceDataChanged",
|
||||
];
|
||||
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
@@ -196,6 +198,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
@@ -196,6 +199,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs",
|
||||
TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.sys.mjs",
|
||||
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||
@@ -19,7 +20,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
});
|
||||
|
||||
ChromeUtils.defineLazyGetter(lazy, "blankURI", () => {
|
||||
@@ -1238,10 +1241,7 @@ var SessionStoreInternal = {
|
||||
@@ -1238,10 +1242,7 @@ var SessionStoreInternal = {
|
||||
*/
|
||||
get willAutoRestore() {
|
||||
return (
|
||||
@@ -31,16 +32,17 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1911,6 +1911,8 @@ var SessionStoreInternal = {
|
||||
@@ -1911,6 +1912,9 @@ var SessionStoreInternal = {
|
||||
case "TabPinned":
|
||||
case "TabUnpinned":
|
||||
case "SwapDocShells":
|
||||
+ case "TabRemovedFromEssentials":
|
||||
+ case "TabAddedToEssentials":
|
||||
+ case "ZenWorkspaceDataChanged":
|
||||
this.saveStateDelayed(win);
|
||||
break;
|
||||
case "TabGroupCreate":
|
||||
@@ -2020,6 +2022,10 @@ var SessionStoreInternal = {
|
||||
@@ -2020,6 +2024,10 @@ var SessionStoreInternal = {
|
||||
this._windows[aWindow.__SSi].isTaskbarTab = true;
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
let tabbrowser = aWindow.gBrowser;
|
||||
|
||||
// add tab change listeners to all already existing tabs
|
||||
@@ -2107,6 +2113,7 @@ var SessionStoreInternal = {
|
||||
@@ -2107,6 +2115,7 @@ var SessionStoreInternal = {
|
||||
null,
|
||||
"sessionstore-one-or-no-tab-restored"
|
||||
);
|
||||
@@ -59,7 +61,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
this._deferredAllWindowsRestored.resolve();
|
||||
}
|
||||
// this window was opened by _openWindowWithState
|
||||
@@ -2151,7 +2158,6 @@ var SessionStoreInternal = {
|
||||
@@ -2151,7 +2160,6 @@ var SessionStoreInternal = {
|
||||
if (closedWindowState) {
|
||||
let newWindowState;
|
||||
if (
|
||||
@@ -67,7 +69,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
!lazy.SessionStartup.willRestore()
|
||||
) {
|
||||
// We want to split the window up into pinned tabs and unpinned tabs.
|
||||
@@ -2215,6 +2221,15 @@ var SessionStoreInternal = {
|
||||
@@ -2215,6 +2223,15 @@ var SessionStoreInternal = {
|
||||
});
|
||||
this._shouldRestoreLastSession = false;
|
||||
}
|
||||
@@ -83,7 +85,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
|
||||
if (this._restoreLastWindow && aWindow.toolbar.visible) {
|
||||
// always reset (if not a popup window)
|
||||
@@ -2465,7 +2480,7 @@ var SessionStoreInternal = {
|
||||
@@ -2465,7 +2482,7 @@ var SessionStoreInternal = {
|
||||
// 2) Flush the window.
|
||||
// 3) When the flush is complete, revisit our decision to store the window
|
||||
// in _closedWindows, and add/remove as necessary.
|
||||
@@ -92,7 +94,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
this.maybeSaveClosedWindow(winData, isLastWindow);
|
||||
}
|
||||
|
||||
@@ -2486,7 +2501,7 @@ var SessionStoreInternal = {
|
||||
@@ -2486,7 +2503,7 @@ var SessionStoreInternal = {
|
||||
|
||||
// Save non-private windows if they have at
|
||||
// least one saveable tab or are the last window.
|
||||
@@ -101,7 +103,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
this.maybeSaveClosedWindow(winData, isLastWindow);
|
||||
|
||||
if (!isLastWindow && winData.closedId > -1) {
|
||||
@@ -2582,6 +2597,7 @@ var SessionStoreInternal = {
|
||||
@@ -2582,6 +2599,7 @@ var SessionStoreInternal = {
|
||||
let alreadyStored = winIndex != -1;
|
||||
// If sidebar command is truthy, i.e. sidebar is open, store sidebar settings
|
||||
let shouldStore = hasSaveableTabs || isLastWindow;
|
||||
@@ -109,7 +111,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
|
||||
if (shouldStore && !alreadyStored) {
|
||||
let index = this._closedWindows.findIndex(win => {
|
||||
@@ -3373,7 +3389,7 @@ var SessionStoreInternal = {
|
||||
@@ -3373,7 +3391,7 @@ var SessionStoreInternal = {
|
||||
if (!isPrivateWindow && tabState.isPrivate) {
|
||||
return;
|
||||
}
|
||||
@@ -118,7 +120,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4089,6 +4105,12 @@ var SessionStoreInternal = {
|
||||
@@ -4089,6 +4107,12 @@ var SessionStoreInternal = {
|
||||
Math.min(tabState.index, tabState.entries.length)
|
||||
);
|
||||
tabState.pinned = false;
|
||||
@@ -131,7 +133,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
|
||||
if (inBackground === false) {
|
||||
aWindow.gBrowser.selectedTab = newTab;
|
||||
@@ -4525,6 +4547,7 @@ var SessionStoreInternal = {
|
||||
@@ -4525,6 +4549,7 @@ var SessionStoreInternal = {
|
||||
// Append the tab if we're opening into a different window,
|
||||
tabIndex: aSource == aTargetWindow ? pos : Infinity,
|
||||
pinned: state.pinned,
|
||||
@@ -139,7 +141,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
userContextId: state.userContextId,
|
||||
skipLoad: true,
|
||||
preferredRemoteType,
|
||||
@@ -5374,7 +5397,7 @@ var SessionStoreInternal = {
|
||||
@@ -5374,7 +5399,7 @@ var SessionStoreInternal = {
|
||||
|
||||
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
|
||||
let tab = tabbrowser.tabs[i];
|
||||
@@ -148,7 +150,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
removableTabs.push(tab);
|
||||
}
|
||||
}
|
||||
@@ -5483,7 +5506,7 @@ var SessionStoreInternal = {
|
||||
@@ -5483,7 +5508,7 @@ var SessionStoreInternal = {
|
||||
|
||||
// collect the data for all windows
|
||||
for (ix in this._windows) {
|
||||
@@ -157,7 +159,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
// window data is still in _statesToRestore
|
||||
continue;
|
||||
}
|
||||
@@ -5625,11 +5648,12 @@ var SessionStoreInternal = {
|
||||
@@ -5625,11 +5650,12 @@ var SessionStoreInternal = {
|
||||
}
|
||||
|
||||
let tabbrowser = aWindow.gBrowser;
|
||||
@@ -171,7 +173,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
// update the internal state data for this window
|
||||
for (let tab of tabs) {
|
||||
if (tab == aWindow.FirefoxViewHandler.tab) {
|
||||
@@ -5640,6 +5664,9 @@ var SessionStoreInternal = {
|
||||
@@ -5640,6 +5666,9 @@ var SessionStoreInternal = {
|
||||
tabsData.push(tabData);
|
||||
}
|
||||
|
||||
@@ -181,7 +183,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
// update tab group state for this window
|
||||
winData.groups = [];
|
||||
for (let tabGroup of aWindow.gBrowser.tabGroups) {
|
||||
@@ -5652,7 +5679,7 @@ var SessionStoreInternal = {
|
||||
@@ -5652,7 +5681,7 @@ var SessionStoreInternal = {
|
||||
// a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab,
|
||||
// since it's only inserted into the tab strip after it's selected).
|
||||
if (aWindow.FirefoxViewHandler.tab?.selected) {
|
||||
@@ -190,7 +192,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
winData.title = tabbrowser.tabs[0].label;
|
||||
}
|
||||
winData.selected = selectedIndex;
|
||||
@@ -5765,8 +5792,8 @@ var SessionStoreInternal = {
|
||||
@@ -5765,8 +5794,8 @@ var SessionStoreInternal = {
|
||||
// selectTab represents.
|
||||
let selectTab = 0;
|
||||
if (overwriteTabs) {
|
||||
@@ -201,7 +203,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
selectTab = Math.min(selectTab, winData.tabs.length);
|
||||
}
|
||||
|
||||
@@ -5788,6 +5815,7 @@ var SessionStoreInternal = {
|
||||
@@ -5788,6 +5817,7 @@ var SessionStoreInternal = {
|
||||
if (overwriteTabs) {
|
||||
for (let i = tabbrowser.browsers.length - 1; i >= 0; i--) {
|
||||
if (!tabbrowser.tabs[i].selected) {
|
||||
@@ -209,7 +211,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
tabbrowser.removeTab(tabbrowser.tabs[i]);
|
||||
}
|
||||
}
|
||||
@@ -5821,6 +5849,9 @@ var SessionStoreInternal = {
|
||||
@@ -5821,6 +5851,9 @@ var SessionStoreInternal = {
|
||||
savedTabGroup => !openTabGroupIdsInWindow.has(savedTabGroup.id)
|
||||
);
|
||||
}
|
||||
@@ -219,7 +221,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
|
||||
// Move the originally open tabs to the end.
|
||||
if (initialTabs) {
|
||||
@@ -6372,6 +6403,25 @@ var SessionStoreInternal = {
|
||||
@@ -6372,6 +6405,25 @@ var SessionStoreInternal = {
|
||||
|
||||
// Most of tabData has been restored, now continue with restoring
|
||||
// attributes that may trigger external events.
|
||||
@@ -245,7 +247,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
|
||||
if (tabData.pinned) {
|
||||
tabbrowser.pinTab(tab);
|
||||
@@ -7290,7 +7340,7 @@ var SessionStoreInternal = {
|
||||
@@ -7290,7 +7342,7 @@ var SessionStoreInternal = {
|
||||
|
||||
let groupsToSave = new Map();
|
||||
for (let tIndex = 0; tIndex < window.tabs.length; ) {
|
||||
@@ -254,7 +256,7 @@ index 2c2f43bf743ef458b378e85e9ed44a971711e1d9..7513021ff75742231f03df4ec598bf29
|
||||
// Adjust window.selected
|
||||
if (tIndex + 1 < window.selected) {
|
||||
window.selected -= 1;
|
||||
@@ -7305,7 +7355,7 @@ var SessionStoreInternal = {
|
||||
@@ -7305,7 +7357,7 @@ var SessionStoreInternal = {
|
||||
);
|
||||
// We don't want to increment tIndex here.
|
||||
continue;
|
||||
|
||||
@@ -868,8 +868,15 @@ class nsZenWorkspaces {
|
||||
let promise = this.#initializeWorkspaces();
|
||||
for (const workspace of spacesFromStore) {
|
||||
const element = this.workspaceElement(workspace.uuid);
|
||||
let wasCollapsed = workspace.hasCollapsedPinnedTabs || false;
|
||||
if (element) {
|
||||
element.collapsiblePins.collapsed = workspace.hasCollapsedPinnedTabs || false;
|
||||
// A bit of a hacky soltuion to ensure that the height
|
||||
// when collapsing is calculated correctly after restoring from session store
|
||||
setTimeout(() => {
|
||||
setTimeout(() => {
|
||||
element.collapsiblePins.collapsed = wasCollapsed;
|
||||
}, 0);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
for (const workspace of this._workspaceCache) {
|
||||
@@ -1323,6 +1330,7 @@ class nsZenWorkspaces {
|
||||
if (!this.#hasInitialized || this.privateWindowOrDisabled) {
|
||||
return;
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent('ZenWorkspaceDataChanged'), { bubbles: true });
|
||||
window.gZenWindowSync.propagateWorkspacesToAllWindows(aSpaceData ?? this._workspaceCache);
|
||||
}
|
||||
|
||||
@@ -1356,17 +1364,15 @@ class nsZenWorkspaces {
|
||||
}
|
||||
// Order the workspace elements correctly
|
||||
let previousElement = null;
|
||||
const arrowScrollbox = document.getElementById('tabbrowser-arrowscrollbox');
|
||||
for (const workspace of aWorkspaces) {
|
||||
const workspaceElement = this.workspaceElement(workspace.uuid);
|
||||
if (workspaceElement) {
|
||||
if (previousElement === null) {
|
||||
gZenUIManager.tabsWrapper.moveBefore(
|
||||
workspaceElement,
|
||||
gZenUIManager.tabsWrapper.firstChild
|
||||
);
|
||||
arrowScrollbox.moveBefore(workspaceElement, arrowScrollbox.firstChild);
|
||||
hasChanged = true;
|
||||
} else if (previousElement.nextSibling !== workspaceElement) {
|
||||
gZenUIManager.tabsWrapper.moveBefore(workspaceElement, previousElement.nextSibling);
|
||||
arrowScrollbox.moveBefore(workspaceElement, previousElement.nextSibling);
|
||||
hasChanged = true;
|
||||
}
|
||||
previousElement = workspaceElement;
|
||||
|
||||
Reference in New Issue
Block a user