mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-03 08:28:38 +00:00
176 lines
6.6 KiB
C++
176 lines
6.6 KiB
C++
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
|
index e8192ea9d8d35165fbfbb8c4fc4a96641a80cc86..cf13724d147c8b8fc35c76d7f77601eb1077ea5c 100644
|
|
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
|
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
|
@@ -126,6 +126,8 @@ const TAB_EVENTS = [
|
|
"TabUngrouped",
|
|
"TabGroupCollapse",
|
|
"TabGroupExpand",
|
|
+ "TabAddedToEssentials",
|
|
+ "TabRemovedFromEssentials",
|
|
];
|
|
|
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
@@ -1898,6 +1900,8 @@ var SessionStoreInternal = {
|
|
case "TabPinned":
|
|
case "TabUnpinned":
|
|
case "SwapDocShells":
|
|
+ case "TabRemovedFromEssentials":
|
|
+ case "TabAddedToEssentials":
|
|
this.saveStateDelayed(win);
|
|
break;
|
|
case "TabGroupCreate":
|
|
@@ -2133,7 +2137,6 @@ var SessionStoreInternal = {
|
|
if (closedWindowState) {
|
|
let newWindowState;
|
|
if (
|
|
- AppConstants.platform == "macosx" ||
|
|
!lazy.SessionStartup.willRestore()
|
|
) {
|
|
// We want to split the window up into pinned tabs and unpinned tabs.
|
|
@@ -2366,11 +2369,9 @@ var SessionStoreInternal = {
|
|
tabbrowser.selectedTab.label;
|
|
}
|
|
|
|
- if (AppConstants.platform != "macosx") {
|
|
// Until we decide otherwise elsewhere, this window is part of a series
|
|
// of closing windows to quit.
|
|
winData._shouldRestore = true;
|
|
- }
|
|
|
|
// Store the window's close date to figure out when each individual tab
|
|
// was closed. This timestamp should allow re-arranging data based on how
|
|
@@ -3355,7 +3356,7 @@ var SessionStoreInternal = {
|
|
if (!isPrivateWindow && tabState.isPrivate) {
|
|
return;
|
|
}
|
|
- if (aTab == aWindow.FirefoxViewHandler.tab) {
|
|
+ if (aTab == aWindow.FirefoxViewHandler.tab || aTab.hasAttribute("zen-empty-tab")) {
|
|
return;
|
|
}
|
|
|
|
@@ -4067,6 +4068,11 @@ var SessionStoreInternal = {
|
|
Math.min(tabState.index, tabState.entries.length)
|
|
);
|
|
tabState.pinned = false;
|
|
+ tabState.zenEssential = false;
|
|
+ tabState.zenPinnedId = null;
|
|
+ tabState.zenIsGlance = false;
|
|
+ tabState.zenGlanceId = null;
|
|
+ tabState.zenHasStaticLabel = false;
|
|
|
|
if (inBackground === false) {
|
|
aWindow.gBrowser.selectedTab = newTab;
|
|
@@ -4503,6 +4509,7 @@ var SessionStoreInternal = {
|
|
// Append the tab if we're opening into a different window,
|
|
tabIndex: aSource == aTargetWindow ? pos : Infinity,
|
|
pinned: state.pinned,
|
|
+ essential: state.zenEssential,
|
|
userContextId: state.userContextId,
|
|
skipLoad: true,
|
|
preferredRemoteType,
|
|
@@ -5358,7 +5365,7 @@ var SessionStoreInternal = {
|
|
|
|
for (let i = tabbrowser.pinnedTabCount; i < tabbrowser.tabs.length; i++) {
|
|
let tab = tabbrowser.tabs[i];
|
|
- if (homePages.includes(tab.linkedBrowser.currentURI.spec)) {
|
|
+ if (homePages.includes(tab.linkedBrowser.currentURI.spec) && !tab.hasAttribute("zen-empty-tab")) {
|
|
removableTabs.push(tab);
|
|
}
|
|
}
|
|
@@ -5418,7 +5425,7 @@ var SessionStoreInternal = {
|
|
}
|
|
|
|
let workspaceID = aWindow.getWorkspaceID();
|
|
- if (workspaceID) {
|
|
+ if (workspaceID && !(this.isLastRestorableWindow() && AppConstants.platform == "macosx")) {
|
|
winData.workspaceID = workspaceID;
|
|
}
|
|
},
|
|
@@ -5609,11 +5616,12 @@ var SessionStoreInternal = {
|
|
}
|
|
|
|
let tabbrowser = aWindow.gBrowser;
|
|
- let tabs = tabbrowser.tabs;
|
|
+ let tabs = aWindow.gZenWorkspaces.allStoredTabs;
|
|
/** @type {WindowStateData} */
|
|
let winData = this._windows[aWindow.__SSi];
|
|
let tabsData = (winData.tabs = []);
|
|
|
|
+ winData.splitViewData = aWindow.gZenViewSplitter?.storeDataForSessionStore();
|
|
// update the internal state data for this window
|
|
for (let tab of tabs) {
|
|
if (tab == aWindow.FirefoxViewHandler.tab) {
|
|
@@ -5624,6 +5632,7 @@ var SessionStoreInternal = {
|
|
tabsData.push(tabData);
|
|
}
|
|
|
|
+ winData.folders = aWindow.gZenFolders?.storeDataForSessionStore() || [];
|
|
// update tab group state for this window
|
|
winData.groups = [];
|
|
for (let tabGroup of aWindow.gBrowser.tabGroups) {
|
|
@@ -5636,7 +5645,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) {
|
|
- selectedIndex = 1;
|
|
+ selectedIndex = 0;
|
|
winData.title = tabbrowser.tabs[0].label;
|
|
}
|
|
winData.selected = selectedIndex;
|
|
@@ -5748,8 +5757,8 @@ var SessionStoreInternal = {
|
|
// selectTab represents.
|
|
let selectTab = 0;
|
|
if (overwriteTabs) {
|
|
- selectTab = parseInt(winData.selected || 1, 10);
|
|
- selectTab = Math.max(selectTab, 1);
|
|
+ selectTab = parseInt(winData.selected || 0, 10);
|
|
+ selectTab = Math.max(selectTab, 0);
|
|
selectTab = Math.min(selectTab, winData.tabs.length);
|
|
}
|
|
|
|
@@ -5792,6 +5801,8 @@ var SessionStoreInternal = {
|
|
winData.tabs,
|
|
winData.groups ?? []
|
|
);
|
|
+ aWindow.gZenFolders?.restoreDataFromSessionStore(winData.folders);
|
|
+ aWindow.gZenViewSplitter?.restoreDataFromSessionStore(winData.splitViewData);
|
|
this._log.debug(
|
|
`restoreWindow, createTabsForSessionRestore returned ${tabs.length} tabs`
|
|
);
|
|
@@ -6349,6 +6360,25 @@ var SessionStoreInternal = {
|
|
|
|
// Most of tabData has been restored, now continue with restoring
|
|
// attributes that may trigger external events.
|
|
+ if (tabData.zenEssential) {
|
|
+ tab.setAttribute("zen-essential", "true");
|
|
+ tabData.pinned = true; // Essential tabs are always pinned.
|
|
+ }
|
|
+ if (tabData.zenIsEmpty) {
|
|
+ tab.setAttribute("zen-empty-tab", "true");
|
|
+ }
|
|
+ if (tabData.zenHasStaticLabel) {
|
|
+ tab.setAttribute("zen-has-static-label", "true");
|
|
+ }
|
|
+ if (tabData.zenPinnedId) {
|
|
+ tab.setAttribute("zen-pin-id", tabData.zenPinnedId);
|
|
+ }
|
|
+ if (tabData.zenDefaultUserContextId) {
|
|
+ tab.setAttribute("zenDefaultUserContextId", true);
|
|
+ }
|
|
+ if (tabData.zenWorkspace) {
|
|
+ tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
|
|
+ }
|
|
|
|
if (tabData.pinned) {
|
|
tabbrowser.pinTab(tab);
|
|
@@ -7264,7 +7294,7 @@ var SessionStoreInternal = {
|
|
|
|
let groupsToSave = new Map();
|
|
for (let tIndex = 0; tIndex < window.tabs.length; ) {
|
|
- if (window.tabs[tIndex].pinned) {
|
|
+ if (window.tabs[tIndex].pinned && false) {
|
|
// Adjust window.selected
|
|
if (tIndex + 1 < window.selected) {
|
|
window.selected -= 1;
|