Refactor workspace settings and improve tab management; remove individual pinned tabs preference, update bootstrap command, and enhance tab removal logic for non-existent workspaces.

This commit is contained in:
mr. M
2025-03-06 14:58:35 +01:00
parent d698c51ce0
commit 671a76bf86
8 changed files with 32 additions and 18 deletions

2
l10n

Submodule l10n updated: b109ad0835...1a15769b8d

View File

@@ -13,7 +13,7 @@
"export": "surfer export", "export": "surfer export",
"init": "npm run download && npm run bootstrap && npm run import", "init": "npm run download && npm run bootstrap && npm run import",
"download": "surfer download", "download": "surfer download",
"bootstrap": "surfer bootstrap && surfer bootstrap", "bootstrap": "surfer bootstrap",
"package": "surfer package", "package": "surfer package",
"update-ff": "python3 scripts/update_ff.py", "update-ff": "python3 scripts/update_ff.py",
"update-ff:raw": "surfer update", "update-ff:raw": "surfer update",

View File

@@ -198,7 +198,6 @@ pref('zen.startup.smooth-scroll-in-tabs', true);
pref('zen.workspaces.disabled_for_testing', false); pref('zen.workspaces.disabled_for_testing', false);
pref('zen.workspaces.hide-deactivated-workspaces', false); pref('zen.workspaces.hide-deactivated-workspaces', false);
pref('zen.workspaces.hide-default-container-indicator', true); pref('zen.workspaces.hide-default-container-indicator', true);
pref('zen.workspaces.individual-pinned-tabs', true);
pref('zen.workspaces.show-icon-strip', true); pref('zen.workspaces.show-icon-strip', 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

@@ -247,7 +247,7 @@
cursor: pointer; cursor: pointer;
appearance: none; appearance: none;
outline: none; outline: none;
color: var(--button-primary-color); color: var(--button-primary-bgcolor);
border-top-left-radius: 0; border-top-left-radius: 0;
border-top-right-radius: 0; border-top-right-radius: 0;

View File

@@ -51,7 +51,7 @@ class SplitNode extends SplitLeafNode {
addChild(child) { addChild(child) {
child.parent = this; child.parent = this;
this._children.push(child); this._children.unshift(child);
} }
} }
@@ -1511,7 +1511,8 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
} }
const containerRect = this.fakeBrowser.getBoundingClientRect(); const containerRect = this.fakeBrowser.getBoundingClientRect();
const dropTarget = document.elementFromPoint((containerRect.left + containerRect.width) * 1.5, event.clientY); const padding = Services.prefs.getIntPref('zen.theme.content-element-separation', 0);
const dropTarget = document.elementFromPoint(containerRect.left + containerRect.width + padding + 5, event.clientY);
const browser = dropTarget?.closest('browser'); const browser = dropTarget?.closest('browser');
if (!browser) { if (!browser) {
@@ -1531,7 +1532,7 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
// Calculate which side of the target browser the drop occurred // Calculate which side of the target browser the drop occurred
// const browserRect = browser.getBoundingClientRect(); // const browserRect = browser.getBoundingClientRect();
// const hoverSide = this.calculateHoverSide(event.clientX, event.clientY, browserRect); // const hoverSide = this.calculateHoverSide(event.clientX, event.clientY, browserRect);
const hoverSide = 'right'; const hoverSide = 'left';
if (droppedOnTab.splitView) { if (droppedOnTab.splitView) {
// Add to existing split view // Add to existing split view

View File

@@ -605,6 +605,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._selectStartPage(); this._selectStartPage();
this._fixTabPositions(); this._fixTabPositions();
this._resolveInitialized(); this._resolveInitialized();
this._clearAnyZombieTabs(); // Dont call with await
} }
} }
@@ -652,6 +653,26 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return !window.toolbar.visible || Services.prefs.getBoolPref('browser.tabs.closeWindowWithLastTab'); return !window.toolbar.visible || Services.prefs.getBoolPref('browser.tabs.closeWindowWithLastTab');
} }
async _clearAnyZombieTabs() {
const tabs = this.allStoredTabs;
const workspaces = await this._workspaces();
for (let tab of tabs) {
const workspaceID = tab.getAttribute('zen-workspace-id');
if (
workspaceID &&
!tab.hasAttribute('zen-essential') &&
!workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID)
) {
// Remove any tabs where their workspace doesn't exist anymore
gBrowser.removeTab(tab, {
animate: false,
skipSessionStore: true,
closeWindowWithLastTab: false,
});
}
}
}
handleTabBeforeClose(tab) { handleTabBeforeClose(tab) {
if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) { if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) {
return null; return null;
@@ -1382,10 +1403,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
_deleteAllTabsInWorkspace(workspaceID) { _deleteAllTabsInWorkspace(workspaceID) {
for (let tab of gBrowser.tabs) { for (let tab of this.allStoredTabs) {
if (tab.getAttribute('zen-workspace-id') === workspaceID) { if (tab.getAttribute('zen-workspace-id') === workspaceID) {
gBrowser.removeTab(tab, { gBrowser.removeTab(tab, {
animate: true, animate: false,
skipSessionStore: true, skipSessionStore: true,
closeWindowWithLastTab: false, closeWindowWithLastTab: false,
}); });
@@ -1508,12 +1529,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const previousWorkspace = await this.getActiveWorkspace(); const previousWorkspace = await this.getActiveWorkspace();
alwaysChange = alwaysChange || onInit; alwaysChange = alwaysChange || onInit;
this.activeWorkspace = window.uuid;
if (previousWorkspace && previousWorkspace.uuid === window.uuid && !alwaysChange) { if (previousWorkspace && previousWorkspace.uuid === window.uuid && !alwaysChange) {
this._cancelSwipeAnimation(); this._cancelSwipeAnimation();
return; return;
} }
this.activeWorkspace = window.uuid;
const containerId = window.containerTabId?.toString(); const containerId = window.containerTabId?.toString();
const workspaces = await this._workspaces(); const workspaces = await this._workspaces();
@@ -1995,6 +2016,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// Switch workspace if needed // Switch workspace if needed
if (workspaceID && workspaceID !== activeWorkspace.uuid && parent.ZenWorkspaces._hasInitializedTabsStrip) { if (workspaceID && workspaceID !== activeWorkspace.uuid && parent.ZenWorkspaces._hasInitializedTabsStrip) {
const workspaces = await parent.ZenWorkspaces._workspaces();
await parent.ZenWorkspaces.changeWorkspace({ uuid: workspaceID }); await parent.ZenWorkspaces.changeWorkspace({ uuid: workspaceID });
} }
} }

View File

@@ -944,11 +944,6 @@ Preferences.addAll([
type: 'bool', type: 'bool',
default: true, default: true,
}, },
{
id: 'zen.workspaces.individual-pinned-tabs',
type: 'bool',
default: true,
},
{ {
id: 'zen.workspaces.show-icon-strip', id: 'zen.workspaces.show-icon-strip',
type: 'bool', type: 'bool',

View File

@@ -20,9 +20,6 @@
<checkbox id="zenWorkspacesHideDefaultContainer" <checkbox id="zenWorkspacesHideDefaultContainer"
data-l10n-id="zen-settings-workspaces-hide-default-container-indicator" data-l10n-id="zen-settings-workspaces-hide-default-container-indicator"
preference="zen.workspaces.hide-default-container-indicator"/> preference="zen.workspaces.hide-default-container-indicator"/>
<checkbox id="zenWorkspacesAllowPinnedTabsForDifferentWorkspaces"
data-l10n-id="zen-settings-workspaces-allow-pinned-tabs-for-different-workspaces"
preference="zen.workspaces.individual-pinned-tabs"/>
<checkbox id="zenWorkspacesDisplayAsIconStrip" <checkbox id="zenWorkspacesDisplayAsIconStrip"
data-l10n-id="zen-settings-workspaces-display-as-icon-strip" data-l10n-id="zen-settings-workspaces-display-as-icon-strip"
preference="zen.workspaces.show-icon-strip"/> preference="zen.workspaces.show-icon-strip"/>