From 4cedd84ac877b4ebdf807eb2991cacfa754e8ac1 Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Fri, 13 Sep 2024 20:12:05 +0200 Subject: [PATCH 1/3] Refactor ZenWorkspaces.mjs to add createContainerTabMenu method --- src/ZenWorkspaces.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index b95a246..b45e999 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -683,6 +683,20 @@ var ZenWorkspaces = { }, // Tab browser utilities + createContainerTabMenu(event) { + let window = event.target.ownerGlobal; + const workspace = this.getActiveWorkspaceFromCache(); + if (!workspace) { + return; + } + let containerTabId = workspace.containerTabId; + return window.createUserContextMenu(event, { + isContextMenu: true, + excludeUserContextId: containerTabId, + showDefaultTab: true, + }); + }, + getContextIdIfNeeded(userContextId) { if (typeof userContextId !== "undefined" || !this.workspaceEnabled) { return [userContextId, false]; From 5a9fb8d7be23cfe72f3a80768355a325f84788bd Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Fri, 13 Sep 2024 22:52:03 +0200 Subject: [PATCH 2/3] Allow pinned tabs to be workspace specific --- src/ZenWorkspaces.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index b45e999..b5d9f73 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -1,3 +1,4 @@ + var ZenWorkspaces = { async init() { let docElement = document.documentElement; @@ -95,7 +96,7 @@ var ZenWorkspaces = { if (tabs.length === 1) { this._createNewTabForWorkspace({ uuid: workspaceID }); // We still need to close other tabs in the workspace - this.changeWorkspace({ uuid: workspaceID }); + this.changeWorkspace({ uuid: workspaceID }, true); } } }, @@ -469,10 +470,15 @@ var ZenWorkspaces = { button.removeAttribute('disabled'); }, + get _shouldAllowPinTab() { + return Services.prefs.getBoolPref('zen.workspaces.individual-pinned-tabs'); + }, + async changeWorkspace(window, onInit = false) { if (!this.workspaceEnabled) { return; } + const shouldAllowPinnedTabs = this._shouldAllowPinTab; let firstTab = undefined; let workspaces = await this._workspaces(); for (let workspace of workspaces.workspaces) { @@ -481,7 +487,7 @@ var ZenWorkspaces = { this.unsafeSaveWorkspaces(workspaces); console.info('ZenWorkspaces: Changing workspace to', window.uuid); for (let tab of gBrowser.tabs) { - if ((tab.getAttribute('zen-workspace-id') === window.uuid && !tab.pinned) || !tab.hasAttribute('zen-workspace-id')) { + if ((tab.getAttribute('zen-workspace-id') === window.uuid && !(tab.pinned && !shouldAllowPinnedTabs)) || !tab.hasAttribute('zen-workspace-id')) { if (!firstTab) { firstTab = tab; } else if (gBrowser.selectedTab === tab) { @@ -504,7 +510,7 @@ var ZenWorkspaces = { } for (let tab of gBrowser.tabs) { if (tab.getAttribute('zen-workspace-id') !== window.uuid) { - gBrowser.hideTab(tab); + gBrowser.hideTab(tab, undefined, shouldAllowPinnedTabs); } } document.documentElement.setAttribute('zen-workspace-id', window.uuid); @@ -512,6 +518,8 @@ var ZenWorkspaces = { await this._updateWorkspacesButton(); await this._propagateWorkspaceData(); await this._updateWorkspacesChangeContextMenu(); + + document.getElementById('tabbrowser-tabs')._positionPinnedTabs(); }, async _updateWorkspacesChangeContextMenu() { From cc4601f0e1460cad750e686f25ac8250519e34e8 Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Fri, 13 Sep 2024 23:01:22 +0200 Subject: [PATCH 3/3] Fixed display when choosing containers for each workspace --- src/ZenWorkspaces.mjs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index b5d9f73..14bdfa9 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -693,10 +693,7 @@ var ZenWorkspaces = { // Tab browser utilities createContainerTabMenu(event) { let window = event.target.ownerGlobal; - const workspace = this.getActiveWorkspaceFromCache(); - if (!workspace) { - return; - } + const workspace = this._workspaceCache.workspaces.find((workspace) => this._contextMenuId === workspace.uuid); let containerTabId = workspace.containerTabId; return window.createUserContextMenu(event, { isContextMenu: true,