Refactor tab management and workspace state handling for improved functionality and consistency

This commit is contained in:
mr. M
2025-02-21 15:38:18 +01:00
parent 62ee67ce80
commit f9656c16bf
3 changed files with 15 additions and 27 deletions

View File

@@ -848,7 +848,7 @@
height: calc(100% - var(--tab-block-margin) * 2);
margin-left: calc(-1 * var(--tab-inline-padding) + var(--tab-block-margin));
margin-right: 4px;
padding: 0 calc(var(--toolbarbutton-inner-padding) - 4px) 0 calc(var(--toolbarbutton-inner-padding) / 4 + var(--tab-inline-padding) - 2px);
padding: 0 calc(var(--toolbarbutton-inner-padding)) 0 calc(var(--toolbarbutton-inner-padding) / 4 + var(--tab-inline-padding));
border-radius: 0;
border-top-left-radius: var(--border-radius-medium);
width: unset;
@@ -868,11 +868,11 @@
&::after {
content: '';
display: block;
width: 2px;
width: 2.5px;
height: 16px;
background: light-dark(rgba(88, 79, 79, 0.02), rgba(255, 255, 255, 0.3));
position: absolute;
right: calc(var(--tab-inline-padding) / 2 - 2px);
right: calc(var(--tab-inline-padding) / 2);
top: 50%;
border-radius: 2px;
transform: rotate(12deg) translateY(-50%);

View File

@@ -216,16 +216,6 @@
gBrowser._setTabLabel(tab, pin.title);
tab.setAttribute('zen-has-static-label', 'true');
}
// Reorder the tab if needed
if (tab._tPos !== pin.position) {
const parent = tab.parentNode;
const isEssential = tab.hasAttribute('zen-essential');
// If we arent an essential, we need to take into account
// that the last child is a separator
const childIndex = isEssential ? pin.position : Math.min(pin.position, parent.children.length - 1);
parent.insertBefore(tab, parent.children[childIndex]);
}
}
// Third pass: create new tabs for pins that don't have tabs
@@ -295,7 +285,7 @@
`#vertical-pinned-tabs-container .zen-workspace-tabs-section[zen-workspace-id="${pin.workspaceUuid}"]`
);
if (container) {
container.insertBefore(newTab, container.lastChild);
container.prepend(newTab);
}
}
gBrowser.tabContainer._invalidateCachedTabs();

View File

@@ -1705,7 +1705,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (!tabToSelect && gBrowser.visibleTabs.length) {
tabToSelect = gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1];
}
if (tabToSelect?.hasAttribute('zen-essential')) {
if (tabToSelect?.hasAttribute('zen-essential') || (tabToSelect?.pinned && tabToSelect?.hasAttribute('pending'))) {
// Never select an essential tab
tabToSelect = null;
}
@@ -1728,9 +1728,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return tabToSelect;
}
async _updateWorkspaceState(window, onInit, tabToSelect) {
async _updateWorkspaceState(workspace, onInit, tabToSelect) {
// Update document state
document.documentElement.setAttribute('zen-workspace-id', window.uuid);
document.documentElement.setAttribute('zen-workspace-id', workspace.uuid);
// Recalculate new tab observers
gBrowser.tabContainer.observe(null, 'nsPref:changed', 'privacy.userContext.enabled');
@@ -1740,17 +1740,17 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
gZenUIManager.updateTabsToolbar();
await this._propagateWorkspaceData({ clearCache: false });
gZenThemePicker.onWorkspaceChange(window);
gZenThemePicker.onWorkspaceChange(workspace);
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = 'none';
await this._animateTabs(window, !onInit && !this._animatingChange, tabToSelect);
await this._organizeWorkspaceStripLocations(window, true);
await this._animateTabs(workspace, !onInit && !this._animatingChange, tabToSelect);
await this._organizeWorkspaceStripLocations(workspace, true);
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = '';
// Notify listeners
if (this._changeListeners?.length) {
for (const listener of this._changeListeners) {
await listener(window, onInit);
await listener(workspace, onInit);
}
}
@@ -1758,7 +1758,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._invalidateBookmarkContainers();
// Update workspace indicator
await this.updateWorkspaceIndicator(window, this.workspaceIndicator);
await this.updateWorkspaceIndicator(workspace, this.workspaceIndicator);
// Fix ctrl+tab behavior. Note, we dont call it with "await" because we dont want to wait for it
this._fixCtrlTabBehavior();
@@ -1851,7 +1851,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
// <= 2 because we have the empty tab and the new tab button
const shouldHideSeparator =
pinnedContainer.children.length === 1 ||
Array.from(arrowScrollbox.children).filter((child) => !child.hasAttribute('hidden')).length <= 2;
Array.from(arrowScrollbox.children).filter(
(child) => !child.hasAttribute('hidden') && !child.hasAttribute('zen-empty-tab')
).length <= 1;
if (shouldHideSeparator) {
pinnedContainer.setAttribute('hide-separator', 'true');
} else {
@@ -2149,10 +2151,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const activeWorkspace = this.getActiveWorkspaceFromCache();
const activeWorkspaceUserContextId = activeWorkspace?.containerTabId;
if ((fromExternal || allowInheritPrincipal === false) && !!activeWorkspaceUserContextId) {
return [activeWorkspaceUserContextId, true, undefined];
}
if (typeof userContextId !== 'undefined' && userContextId !== activeWorkspaceUserContextId) {
return [userContextId, false, undefined];
}