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",
"init": "npm run download && npm run bootstrap && npm run import",
"download": "surfer download",
"bootstrap": "surfer bootstrap && surfer bootstrap",
"bootstrap": "surfer bootstrap",
"package": "surfer package",
"update-ff": "python3 scripts/update_ff.py",
"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.hide-deactivated-workspaces', false);
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.force-container-workspace', false);
pref('zen.workspaces.open-new-tab-if-last-unpinned-tab-is-closed', false);

View File

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

View File

@@ -51,7 +51,7 @@ class SplitNode extends SplitLeafNode {
addChild(child) {
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 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');
if (!browser) {
@@ -1531,7 +1532,7 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
// Calculate which side of the target browser the drop occurred
// const browserRect = browser.getBoundingClientRect();
// const hoverSide = this.calculateHoverSide(event.clientX, event.clientY, browserRect);
const hoverSide = 'right';
const hoverSide = 'left';
if (droppedOnTab.splitView) {
// Add to existing split view

View File

@@ -605,6 +605,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._selectStartPage();
this._fixTabPositions();
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');
}
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) {
if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) {
return null;
@@ -1382,10 +1403,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
_deleteAllTabsInWorkspace(workspaceID) {
for (let tab of gBrowser.tabs) {
for (let tab of this.allStoredTabs) {
if (tab.getAttribute('zen-workspace-id') === workspaceID) {
gBrowser.removeTab(tab, {
animate: true,
animate: false,
skipSessionStore: true,
closeWindowWithLastTab: false,
});
@@ -1508,12 +1529,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const previousWorkspace = await this.getActiveWorkspace();
alwaysChange = alwaysChange || onInit;
this.activeWorkspace = window.uuid;
if (previousWorkspace && previousWorkspace.uuid === window.uuid && !alwaysChange) {
this._cancelSwipeAnimation();
return;
}
this.activeWorkspace = window.uuid;
const containerId = window.containerTabId?.toString();
const workspaces = await this._workspaces();
@@ -1995,6 +2016,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// Switch workspace if needed
if (workspaceID && workspaceID !== activeWorkspace.uuid && parent.ZenWorkspaces._hasInitializedTabsStrip) {
const workspaces = await parent.ZenWorkspaces._workspaces();
await parent.ZenWorkspaces.changeWorkspace({ uuid: workspaceID });
}
}

View File

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

View File

@@ -20,9 +20,6 @@
<checkbox id="zenWorkspacesHideDefaultContainer"
data-l10n-id="zen-settings-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"
data-l10n-id="zen-settings-workspaces-display-as-icon-strip"
preference="zen.workspaces.show-icon-strip"/>