fix: Fix ZenWorkspaces initialization in hidden windows and private browsing mode

This commit is contained in:
Mauro Balades
2024-07-19 17:36:57 +02:00
parent a0f30e595b
commit 80f8e829df
5 changed files with 30 additions and 14 deletions

View File

@@ -165,3 +165,6 @@ pref('zen.splitView.working', false);
// Zen Workspaces // Zen Workspaces
pref('zen.workspaces.enabled', true); pref('zen.workspaces.enabled', true);
// Zen Watermark
pref('zen.watermark.enabled', true);

View File

@@ -3,10 +3,11 @@ var ZenWorkspaces = {
async init() { async init() {
let docElement = document.documentElement; let docElement = document.documentElement;
if (docElement.getAttribute("chromehidden").includes("toolbar") if (docElement.getAttribute("chromehidden").includes("toolbar")
|| docElement.getAttribute("chromehidden").includes("menubar")) { || docElement.getAttribute("chromehidden").includes("menubar")
|| docElement.hasAttribute("privatebrowsingmode")) {
console.log("!!! ZenWorkspaces is disabled in hidden windows !!!"); console.log("!!! ZenWorkspaces is disabled in hidden windows !!!");
return; // We are in a hidden window, don't initialize ZenWorkspaces return; // We are in a hidden window, don't initialize ZenWorkspaces
} }
console.log("Initializing ZenWorkspaces..."); console.log("Initializing ZenWorkspaces...");
await this.initializeWorkspaces(); await this.initializeWorkspaces();
console.log("ZenWorkspaces initialized"); console.log("ZenWorkspaces initialized");

View File

@@ -1,13 +1,14 @@
diff --git a/browser/base/content/browser-init.js b/browser/base/content/browser-init.js diff --git a/browser/base/content/browser-init.js b/browser/base/content/browser-init.js
index a79a9734619f89639c15087fe28e9615354a7209..212628c6fb2bed5ba17a3d2908f5d4b2376fa95e 100644 index a79a9734619f89639c15087fe28e9615354a7209..b7e6a413e02ed047e19de1db3866087a1fdc5c4a 100644
--- a/browser/base/content/browser-init.js --- a/browser/base/content/browser-init.js
+++ b/browser/base/content/browser-init.js +++ b/browser/base/content/browser-init.js
@@ -230,6 +230,8 @@ var gBrowserInit = { @@ -237,6 +237,9 @@ var gBrowserInit = {
gURLBar.readOnly = true; gPrivateBrowsingUI.init();
} BrowserSearch.init();
BrowserPageActions.init();
+
+ Services.scriptloader.loadSubScript("chrome://browser/content/zenThemeModifier.js", this); + Services.scriptloader.loadSubScript("chrome://browser/content/zenThemeModifier.js", this);
+ +
// Misc. inits. if (gToolbarKeyNavEnabled) {
gUIDensity.init(); ToolbarKeyboardNavigator.init();
TabletModeUpdater.init(); }

View File

@@ -128,13 +128,20 @@
let profile = ProfileService.currentProfile; let profile = ProfileService.currentProfile;
if (!profile || profile.zenAvatarPath == "") return; if (!profile || profile.zenAvatarPath == "") return;
// TODO: actually use profile data to generate the avatar, instead of just using the name // TODO: actually use profile data to generate the avatar, instead of just using the name
console.log("ZenThemeModifier: setting avatar image to", profile.zenAvatarPath); let avatarUrl = profile.zenAvatarPath;
mainWindowEl.style.setProperty("--zen-avatar-image-url", `url(${profile.zenAvatarPath})`); if (document.documentElement.hasAttribute("privatebrowsingmode")) {
avatarUrl = "chrome://global/skin/icons/indicator-private-browsing.svg";
}
console.log("ZenThemeModifier: setting avatar image to", avatarUrl);
mainWindowEl.style.setProperty("--zen-avatar-image-url", `url(${avatarUrl})`);
mainWindowEl.style.setProperty("--avatar-image-url", `var(--zen-avatar-image-url)`, "important"); mainWindowEl.style.setProperty("--avatar-image-url", `var(--zen-avatar-image-url)`, "important");
this.closeWatermark(); this.closeWatermark();
}, },
openWatermark() { openWatermark() {
if (!Services.prefs.getBoolPref("zen.watermark.enabled", false)) {
return;
}
const watermark = document.getElementById("zen-watermark"); const watermark = document.getElementById("zen-watermark");
if (watermark) { if (watermark) {
watermark.removeAttribute("hidden"); watermark.removeAttribute("hidden");

View File

@@ -334,6 +334,10 @@ toolbarbutton#scrollbutton-up {
background: var(--toolbarbutton-hover-background); background: var(--toolbarbutton-hover-background);
} }
#private-browsing-indicator-with-label {
display: none !important;
}
.tabbrowser-tab::after { .tabbrowser-tab::after {
background: var(--identity-tab-color, transparent); background: var(--identity-tab-color, transparent);
border-radius: 2px; border-radius: 2px;
@@ -607,7 +611,7 @@ panelmultiview {
#zen-watermark[hidden="true"] { #zen-watermark[hidden="true"] {
transition: 0.6s; transition: 0.6s;
transition-delay: 1.5s; transition-delay: .5s;
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
} }