From 70f4803ca3f44a655ec7dbfc3ffd271370982937 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Fri, 4 Sep 2026 12:57:47 +0200 Subject: [PATCH] gh-15232: Fixed syncing themes not updating the color scheme (gh-15233) --- src/zen/spaces/ZenGradientGenerator.mjs | 14 ++++++-------- src/zen/spaces/ZenSpace.mjs | 15 +-------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/zen/spaces/ZenGradientGenerator.mjs b/src/zen/spaces/ZenGradientGenerator.mjs index cc423bc39..83f2f194a 100644 --- a/src/zen/spaces/ZenGradientGenerator.mjs +++ b/src/zen/spaces/ZenGradientGenerator.mjs @@ -1509,7 +1509,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature { baseColor = this.blendColors( accentColor, baseColor.slice(0, 3), - this.canBeTransparent ? 25 : 5 + this.canBeTransparent ? 20 : 5 ).concat(opacity); } return baseColor; @@ -1538,16 +1538,16 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature { return; } + if (theme === null) { + browser.gZenThemePicker.invalidateGradientCache(uuid); + } + // Do not rebuild if the workspace is not the same as the current one const windowWorkspace = browser.gZenWorkspaces.getActiveWorkspace(); if (windowWorkspace.uuid !== uuid) { return; } - if (theme === null) { - browser.gZenThemePicker.invalidateGradientCache(uuid); - } - // get the theme from the window workspaceTheme = this.fixTheme(theme || windowWorkspace.theme); const docElement = browser.document.documentElement; @@ -1983,9 +1983,7 @@ export class nsZenThemePicker extends nsZenMultiWindowFeature { invalidateGradientCache(uuid) { delete this.#gradientsCache[uuid]; - window.dispatchEvent( - new Event("ZenGradientCacheChanged", { bubbles: true }) - ); + gZenWorkspaces.workspaceElement(uuid)?.onGradientCacheChanged(); } getGradientForWorkspace(workspace, { getGradient = true } = {}) { diff --git a/src/zen/spaces/ZenSpace.mjs b/src/zen/spaces/ZenSpace.mjs index 67556a64a..378c5eb73 100644 --- a/src/zen/spaces/ZenSpace.mjs +++ b/src/zen/spaces/ZenSpace.mjs @@ -268,12 +268,6 @@ export class nsZenWorkspace extends MozXULElement { this.#updateOverflow(); - this.onGradientCacheChanged = this.#onGradientCacheChanged.bind(this); - window.addEventListener( - "ZenGradientCacheChanged", - this.onGradientCacheChanged - ); - this.pinnedTabsContainer.addEventListener("TabPinned", () => { // If a tab is pinned and the pinned tabs section is collapsed, uncollapse it. if (this.collapsiblePins.collapsed) { @@ -300,13 +294,6 @@ export class nsZenWorkspace extends MozXULElement { }); } - disconnectedCallback() { - window.removeEventListener( - "ZenGradientCacheChanged", - this.onGradientCacheChanged - ); - } - get active() { return this.hasAttribute("active"); } @@ -395,7 +382,7 @@ export class nsZenWorkspace extends MozXULElement { return this.querySelector("#tabs-newtab-button"); } - #onGradientCacheChanged() { + onGradientCacheChanged() { const { isDarkMode, isExplicitMode, toolbarColor, primaryColor } = gZenThemePicker.getGradientForWorkspace( gZenWorkspaces.getWorkspaceFromId(this.workspaceUuid),