1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-10 05:35:29 +02:00

feat: Added an option to restore tabs from where they left off, b=(no-bug), c=common, workspaces

This commit is contained in:
mr. m 2025-05-06 14:34:47 +02:00
parent 53332937c2
commit 6f88c5d2d1
No known key found for this signature in database
GPG key ID: 419302196C23B258
7 changed files with 65 additions and 54 deletions

2
l10n

@ -1 +1 @@
Subproject commit 9a673b4339956fe7d19460e024310f8b5693b149 Subproject commit 70534bcec754b1cd108f275708cfba4427d0b7d4

View file

@ -109,6 +109,7 @@ pref('zen.watermark.enabled', false, sticky);
pref('zen.startup.smooth-scroll-in-tabs', true); pref('zen.startup.smooth-scroll-in-tabs', true);
// Zen Workspaces // Zen Workspaces
pref('zen.workspaces.continue-where-left-off', false);
pref('zen.workspaces.hide-default-container-indicator', true); pref('zen.workspaces.hide-default-container-indicator', true);
pref('zen.workspaces.force-container-workspace', false); pref('zen.workspaces.force-container-workspace', false);
pref('zen.workspaces.open-new-tab-if-last-unpinned-tab-is-closed', false); pref('zen.workspaces.open-new-tab-if-last-unpinned-tab-is-closed', false);

View file

@ -1,8 +1,18 @@
diff --git a/browser/components/preferences/main.inc.xhtml b/browser/components/preferences/main.inc.xhtml diff --git a/browser/components/preferences/main.inc.xhtml b/browser/components/preferences/main.inc.xhtml
index cdcf50ec1bc4a54c69f5baf4a6d40ab0c63a8121..87603323c2b0b9ea0c847a8a06e293a16c1252b8 100644 index f9129fb171362e81369056923bf25acbb87d2ad8..924bcd2cd66a5dfcf9c45aac0c63cd0257c21a2c 100644
--- a/browser/components/preferences/main.inc.xhtml --- a/browser/components/preferences/main.inc.xhtml
+++ b/browser/components/preferences/main.inc.xhtml +++ b/browser/components/preferences/main.inc.xhtml
@@ -183,6 +183,7 @@ @@ -29,6 +29,9 @@
<vbox id="startupPageBox">
<checkbox id="browserRestoreSession"
data-l10n-id="startup-restore-windows-and-tabs"/>
+ <checkbox id="zenWorkspaceContinueWhereLeftOff"
+ data-l10n-id="zen-workspace-continue-where-left-off"
+ preference="zen.workspaces.continue-where-left-off"/>
#ifdef XP_WIN
<hbox id="windowsLaunchOnLoginBox" align="center" hidden="true">
<checkbox id="windowsLaunchOnLogin"
@@ -186,6 +189,7 @@
</groupbox> </groupbox>
<!-- Browser layout --> <!-- Browser layout -->
@ -10,7 +20,7 @@ index cdcf50ec1bc4a54c69f5baf4a6d40ab0c63a8121..87603323c2b0b9ea0c847a8a06e293a1
<groupbox data-category="paneGeneral" <groupbox data-category="paneGeneral"
data-subcategory="layout" data-subcategory="layout"
hidden="true"> hidden="true">
@@ -198,6 +199,7 @@ @@ -201,6 +205,7 @@
preference="sidebar.revamp"/> preference="sidebar.revamp"/>
<description class="indent" data-l10n-id="browser-layout-show-sidebar-desc"></description> <description class="indent" data-l10n-id="browser-layout-show-sidebar-desc"></description>
</groupbox> </groupbox>
@ -18,7 +28,7 @@ index cdcf50ec1bc4a54c69f5baf4a6d40ab0c63a8121..87603323c2b0b9ea0c847a8a06e293a1
<hbox id="languageAndAppearanceCategory" <hbox id="languageAndAppearanceCategory"
class="subcategory" class="subcategory"
@@ -411,6 +413,7 @@ @@ -421,6 +426,7 @@
languages-customize-add.label, languages-customize-add.label,
" /> " />
</hbox> </hbox>

View file

@ -1151,4 +1151,9 @@ Preferences.addAll([
type: 'bool', type: 'bool',
default: true, default: true,
}, },
{
id: 'zen.workspaces.continue-where-left-off',
type: 'bool',
default: false,
},
]); ]);

View file

@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c352b425006 100644 index 6dece2b9d0462d90a28e75350ce983d87816ef73..2fd408bd7c6c73ee0106fef75a80f2a9c4e105d5 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js --- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -415,11 +415,58 @@ @@ -415,11 +415,58 @@
@ -389,15 +389,15 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
); );
tabsFragment.appendChild(tabGroup.node); tabsFragment.appendChild(tabGroup.node);
} }
@@ -3723,8 +3863,15 @@ @@ -3723,8 +3863,13 @@
// to remove the old selected tab. // to remove the old selected tab.
if (tabToSelect) { if (tabToSelect) {
let leftoverTab = this.selectedTab; let leftoverTab = this.selectedTab;
+ if (tabToSelect.pinned) { - this.selectedTab = tabToSelect;
- this.removeTab(leftoverTab);
+ ZenWorkspaces._tabToRemoveForEmpty = leftoverTab; + ZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
+ } else { + if (Services.prefs.getBoolPref("zen.workspaces.continue-where-left-off")) {
this.selectedTab = tabToSelect; + ZenWorkspaces._tabToSelect = tabToSelect;
this.removeTab(leftoverTab);
+ } + }
+ } + }
+ else { + else {
@ -405,7 +405,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} }
if (tabs.length > 1 || !tabs[0].selected) { if (tabs.length > 1 || !tabs[0].selected) {
@@ -3912,7 +4059,7 @@ @@ -3912,7 +4057,7 @@
// Ensure we have an index if one was not provided. // Ensure we have an index if one was not provided.
if (typeof index != "number") { if (typeof index != "number") {
// Move the new tab after another tab if needed, to the end otherwise. // Move the new tab after another tab if needed, to the end otherwise.
@ -414,7 +414,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if ( if (
!bulkOrderedOpen && !bulkOrderedOpen &&
((openerTab && ((openerTab &&
@@ -3958,18 +4105,18 @@ @@ -3958,18 +4103,18 @@
// Ensure index is within bounds. // Ensure index is within bounds.
if (tab.pinned) { if (tab.pinned) {
@ -437,7 +437,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) { if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group // Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, itemAfter); this.tabContainer.insertBefore(tab, itemAfter);
@@ -4290,6 +4437,9 @@ @@ -4290,6 +4435,9 @@
return; return;
} }
@ -447,7 +447,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
this.removeTabs(selectedTabs, { telemetrySource }); this.removeTabs(selectedTabs, { telemetrySource });
} }
@@ -4542,6 +4692,7 @@ @@ -4542,6 +4690,7 @@
telemetrySource, telemetrySource,
} = {} } = {}
) { ) {
@ -455,7 +455,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs // When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window. // can be considered equivalent to closing the window.
if ( if (
@@ -4626,6 +4777,7 @@ @@ -4626,6 +4775,7 @@
if (lastToClose) { if (lastToClose) {
this.removeTab(lastToClose, aParams); this.removeTab(lastToClose, aParams);
} }
@ -463,7 +463,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@@ -4650,6 +4802,7 @@ @@ -4650,6 +4800,7 @@
telemetrySource, telemetrySource,
} = {} } = {}
) { ) {
@ -471,7 +471,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (UserInteraction.running("browser.tabs.opening", window)) { if (UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.finish("browser.tabs.opening", window); UserInteraction.finish("browser.tabs.opening", window);
} }
@@ -4663,6 +4816,12 @@ @@ -4663,6 +4814,12 @@
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start(); aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
} }
@ -484,7 +484,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// Handle requests for synchronously removing an already // Handle requests for synchronously removing an already
// asynchronously closing tab. // asynchronously closing tab.
if (!animate && aTab.closing) { if (!animate && aTab.closing) {
@@ -4677,7 +4836,9 @@ @@ -4677,7 +4834,9 @@
// frame created for it (for example, by updating the visually selected // frame created for it (for example, by updating the visually selected
// state). // state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width; let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@ -495,7 +495,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if ( if (
!this._beginRemoveTab(aTab, { !this._beginRemoveTab(aTab, {
closeWindowFastpath: true, closeWindowFastpath: true,
@@ -4840,7 +5001,7 @@ @@ -4840,7 +4999,7 @@
closeWindowWithLastTab != null closeWindowWithLastTab != null
? closeWindowWithLastTab ? closeWindowWithLastTab
: !window.toolbar.visible || : !window.toolbar.visible ||
@ -504,7 +504,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (closeWindow) { if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here, // We've already called beforeunload on all the relevant tabs if we get here,
@@ -4864,6 +5025,7 @@ @@ -4864,6 +5023,7 @@
newTab = true; newTab = true;
} }
@ -512,7 +512,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
aTab._endRemoveArgs = [closeWindow, newTab]; aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation. // swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -4903,9 +5065,7 @@ @@ -4903,9 +5063,7 @@
aTab._mouseleave(); aTab._mouseleave();
if (newTab) { if (newTab) {
@ -523,7 +523,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} else { } else {
TabBarVisibility.update(); TabBarVisibility.update();
} }
@@ -5034,6 +5194,8 @@ @@ -5034,6 +5192,8 @@
this.tabs[i]._tPos = i; this.tabs[i]._tPos = i;
} }
@ -532,7 +532,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (!this._windowIsClosing) { if (!this._windowIsClosing) {
if (wasPinned) { if (wasPinned) {
this.tabContainer._positionPinnedTabs(); this.tabContainer._positionPinnedTabs();
@@ -5159,8 +5321,8 @@ @@ -5159,8 +5319,8 @@
return closedCount; return closedCount;
} }
@ -543,7 +543,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (unloadBlocked) { if (unloadBlocked) {
return; return;
} }
@@ -5248,6 +5410,7 @@ @@ -5248,6 +5408,7 @@
} }
let excludeTabs = new Set(aExcludeTabs); let excludeTabs = new Set(aExcludeTabs);
@ -551,7 +551,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// If this tab has a successor, it should be selectable, since // If this tab has a successor, it should be selectable, since
// hiding or closing a tab removes that tab as a successor. // hiding or closing a tab removes that tab as a successor.
@@ -5260,13 +5423,13 @@ @@ -5260,13 +5421,13 @@
!excludeTabs.has(aTab.owner) && !excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose") Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) { ) {
@ -567,7 +567,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
); );
let tab = this.tabContainer.findNextTab(aTab, { let tab = this.tabContainer.findNextTab(aTab, {
@@ -5282,7 +5445,7 @@ @@ -5282,7 +5443,7 @@
} }
if (tab) { if (tab) {
@ -576,7 +576,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} }
// If no qualifying visible tab was found, see if there is a tab in // If no qualifying visible tab was found, see if there is a tab in
@@ -5303,7 +5466,7 @@ @@ -5303,7 +5464,7 @@
}); });
} }
@ -585,7 +585,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} }
_blurTab(aTab) { _blurTab(aTab) {
@@ -5704,10 +5867,10 @@ @@ -5704,10 +5865,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy"); SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
} }
@ -598,7 +598,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
aTab.selected || aTab.selected ||
aTab.closing || aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden. // Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -6001,7 +6164,7 @@ @@ -6001,7 +6162,7 @@
// Don't allow mixing pinned and unpinned tabs. // Don't allow mixing pinned and unpinned tabs.
if (this.isTab(element) && element.pinned) { if (this.isTab(element) && element.pinned) {
@ -607,7 +607,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
} else { } else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount); tabIndex = Math.max(tabIndex, this.pinnedTabCount);
} }
@@ -6028,9 +6191,16 @@ @@ -6028,9 +6189,16 @@
element, element,
() => { () => {
let neighbor = this.tabs[tabIndex]; let neighbor = this.tabs[tabIndex];
@ -625,7 +625,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (neighbor && this.isTab(element) && tabIndex > element._tPos) { if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
neighbor.after(element); neighbor.after(element);
} else { } else {
@@ -6099,7 +6269,9 @@ @@ -6099,7 +6267,9 @@
targetElement = targetElement.group; targetElement = targetElement.group;
} }
} }
@ -636,7 +636,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// Don't allow mixing pinned and unpinned tabs. // Don't allow mixing pinned and unpinned tabs.
if (element.pinned && !targetElement?.pinned) { if (element.pinned && !targetElement?.pinned) {
targetElement = this.tabs[this.pinnedTabCount - 1]; targetElement = this.tabs[this.pinnedTabCount - 1];
@@ -6109,7 +6281,13 @@ @@ -6109,7 +6279,13 @@
moveBefore = true; moveBefore = true;
} }
@ -650,7 +650,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
if (element.pinned && this.tabContainer.verticalMode) { if (element.pinned && this.tabContainer.verticalMode) {
return this.tabContainer.verticalPinnedTabsContainer; return this.tabContainer.verticalPinnedTabsContainer;
} }
@@ -6169,7 +6347,7 @@ @@ -6169,7 +6345,7 @@
if (!this.isTab(aTab)) { if (!this.isTab(aTab)) {
throw new Error("Can only move a tab into a tab group"); throw new Error("Can only move a tab into a tab group");
} }
@ -659,7 +659,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
return; return;
} }
if (aTab.group && aTab.group.id === aGroup.id) { if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6263,6 +6441,10 @@ @@ -6263,6 +6439,10 @@
moveActionCallback(); moveActionCallback();
@ -670,7 +670,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// Clear tabs cache after moving nodes because the order of tabs may have // Clear tabs cache after moving nodes because the order of tabs may have
// changed. // changed.
this.tabContainer._invalidateCachedTabs(); this.tabContainer._invalidateCachedTabs();
@@ -7080,7 +7262,7 @@ @@ -7080,7 +7260,7 @@
// preventDefault(). It will still raise the window if appropriate. // preventDefault(). It will still raise the window if appropriate.
break; break;
} }
@ -679,7 +679,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
window.focus(); window.focus();
aEvent.preventDefault(); aEvent.preventDefault();
break; break;
@@ -7981,6 +8163,7 @@ @@ -7981,6 +8161,7 @@
aWebProgress.isTopLevel aWebProgress.isTopLevel
) { ) {
this.mTab.setAttribute("busy", "true"); this.mTab.setAttribute("busy", "true");
@ -687,7 +687,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
gBrowser._tabAttrModified(this.mTab, ["busy"]); gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected; this.mTab._notselectedsinceload = !this.mTab.selected;
} }
@@ -8954,7 +9137,7 @@ var TabContextMenu = { @@ -8954,7 +9135,7 @@ var TabContextMenu = {
); );
contextUnpinSelectedTabs.hidden = contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected; !this.contextTab.pinned || !this.multiselected;
@ -696,7 +696,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4cc07f008d99138a76c8e9813c857c35
// Move Tab items // Move Tab items
let contextMoveTabOptions = document.getElementById( let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions" "context_moveTabOptions"
@@ -9223,6 +9406,7 @@ var TabContextMenu = { @@ -9223,6 +9404,7 @@ var TabContextMenu = {
telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP, telemetrySource: gBrowser.TabMetrics.METRIC_SOURCE.TAB_STRIP,
}); });
} else { } else {

View file

@ -528,6 +528,10 @@ button.popup-notification-dropmarker {
border-radius: 4px !important; border-radius: 4px !important;
} }
.urlbarView-userContext {
padding-top: 0px !important;
}
.urlbarView-row[has-action]:is([type='switchtab'], [type='remotetab'], [type='clipboard']) { .urlbarView-row[has-action]:is([type='switchtab'], [type='remotetab'], [type='clipboard']) {
& .urlbarView-action { & .urlbarView-action {
margin-left: auto !important; margin-left: auto !important;

View file

@ -800,28 +800,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._initialTab._possiblyEmpty = false; this._initialTab._possiblyEmpty = false;
this._initialTab = null; this._initialTab = null;
} }
const currentTab = gBrowser.selectedTab;
let showed = false; let showed = false;
if (this._tabToRemoveForEmpty) { if (this._tabToRemoveForEmpty) {
if (gZenVerticalTabsManager._canReplaceNewTab) { if (gZenVerticalTabsManager._canReplaceNewTab) {
this.selectEmptyTab(); if (this._tabToSelect) {
gBrowser.selectedTab = this._tabToSelect;
delete this._tabToSelect;
} else {
this.selectEmptyTab();
}
gBrowser.removeTab(this._tabToRemoveForEmpty); gBrowser.removeTab(this._tabToRemoveForEmpty);
showed = true; showed = true;
} }
delete this._tabToRemoveForEmpty; delete this._tabToRemoveForEmpty;
} else {
const currentTabURL = currentTab.linkedBrowser?.currentURI?.spec;
// Check for empty tab being restored
if (
(currentTab.isEmpty &&
(currentTab.getAttribute('image') === gPageIcons[currentTabURL] || !currentTab.hasAttribute('image'))) ||
currentTab._possiblyEmpty
) {
this.selectEmptyTab();
this._removedByStartupPage = true;
gBrowser.removeTab(currentTab);
showed = true;
}
} }
if (gZenVerticalTabsManager._canReplaceNewTab && showed) { if (gZenVerticalTabsManager._canReplaceNewTab && showed) {
BrowserCommands.openTab(); BrowserCommands.openTab();