Fixed opening customizable toolbar while having multiple windows (closes https://github.com/zen-browser/desktop/issues/3819)

This commit is contained in:
mr. M
2024-12-21 19:50:17 +01:00
parent 929e7cbaab
commit 47f66049d7
4 changed files with 27 additions and 17 deletions

View File

@@ -61,7 +61,7 @@ ac_add_options --enable-alsa
ac_add_options --enable-pulseaudio ac_add_options --enable-pulseaudio
if test "$ZEN_RELEASE"; then if test "$ZEN_RELEASE"; then
#ac_add_options --enable-clang-plugin ac_add_options --enable-clang-plugin
# Disable DMD and ELF hacks, enable linker lld # Disable DMD and ELF hacks, enable linker lld
ac_add_options --disable-dmd ac_add_options --disable-dmd

View File

@@ -117,6 +117,8 @@ var gZenUIManager = {
var gZenVerticalTabsManager = { var gZenVerticalTabsManager = {
init() { init() {
this._multiWindowFeature = new ZenMultiWindowFeature();
ChromeUtils.defineLazyGetter(this, 'isWindowsStyledButtons', () => { ChromeUtils.defineLazyGetter(this, 'isWindowsStyledButtons', () => {
return !(window.AppConstants.platform === 'macosx' || window.matchMedia('(-moz-gtk-csd-reversed-placement)').matches return !(window.AppConstants.platform === 'macosx' || window.matchMedia('(-moz-gtk-csd-reversed-placement)').matches
|| Services.prefs.getBoolPref('zen.view.experimental-force-window-controls-left')); || Services.prefs.getBoolPref('zen.view.experimental-force-window-controls-left'));
@@ -138,7 +140,7 @@ var gZenVerticalTabsManager = {
this.initRightSideOrderContextMenu(); this.initRightSideOrderContextMenu();
window.addEventListener('customizationstarting', this._preCustomize.bind(this)); window.addEventListener('customizationstarting', this._preCustomize.bind(this));
window.addEventListener('aftercustomization', updateEvent); window.addEventListener('aftercustomization', this._postCustomize.bind(this));
window.addEventListener('DOMContentLoaded', updateEvent, { once: true }); window.addEventListener('DOMContentLoaded', updateEvent, { once: true });
@@ -209,12 +211,22 @@ var gZenVerticalTabsManager = {
return this.__actualWindowButtons; return this.__actualWindowButtons;
}, },
_preCustomize() { async _preCustomize() {
this._updateEvent({ forceMultipleToolbar: true }); await this._multiWindowFeature.foreachWindowAsActive(async (browser) => {
browser.gZenVerticalTabsManager._updateEvent({ forceMultipleToolbar: true, dontRebuildAreas: true });
});
this.rebuildAreas();
this.navigatorToolbox.setAttribute('zen-sidebar-expanded', 'true'); this.navigatorToolbox.setAttribute('zen-sidebar-expanded', 'true');
document.documentElement.setAttribute('zen-sidebar-expanded', 'true'); // force expanded sidebar document.documentElement.setAttribute('zen-sidebar-expanded', 'true'); // force expanded sidebar
}, },
_postCustomize() {
// No need to use `await` here, because the customization is already done
this._multiWindowFeature.foreachWindowAsActive(async (browser) => {
browser.gZenVerticalTabsManager._updateEvent({ dontRebuildAreas: true });
});
},
initializePreferences(updateEvent) { initializePreferences(updateEvent) {
XPCOMUtils.defineLazyPreferenceGetter( XPCOMUtils.defineLazyPreferenceGetter(
this, this,
@@ -261,7 +273,7 @@ var gZenVerticalTabsManager = {
); );
}, },
_updateEvent({ forceMultipleToolbar = false } = {}) { _updateEvent({ forceMultipleToolbar = false, dontRebuildAreas = false } = {}) {
if (this._isUpdating) { if (this._isUpdating) {
return; return;
} }
@@ -314,16 +326,8 @@ var gZenVerticalTabsManager = {
!isCompactMode !isCompactMode
) { ) {
this.navigatorToolbox.prepend(topButtons); this.navigatorToolbox.prepend(topButtons);
// browser.prepend(this.navigatorToolbox);
} else {
// customizationTarget.prepend(topButtons);
// tabboxWrapper.prepend(this.navigatorToolbox);
} }
//if (!isVerticalTabs) {
// document.getElementById("urlbar-container").after(document.getElementById('navigator-toolbox'));
//}
let windowButtons = this.actualWindowButtons; let windowButtons = this.actualWindowButtons;
let doNotChangeWindowButtons = !isCompactMode && isRightSide && this.isWindowsStyledButtons; let doNotChangeWindowButtons = !isCompactMode && isRightSide && this.isWindowsStyledButtons;
const navBar = document.getElementById('nav-bar'); const navBar = document.getElementById('nav-bar');
@@ -365,8 +369,10 @@ var gZenVerticalTabsManager = {
document.documentElement.removeAttribute("zen-single-toolbar"); document.documentElement.removeAttribute("zen-single-toolbar");
navBar.appendChild(document.getElementById('PanelUI-button')); navBar.appendChild(document.getElementById('PanelUI-button'));
this._toolbarOriginalParent.prepend(navBar); this._toolbarOriginalParent.prepend(navBar);
if (!dontRebuildAreas) {
this.rebuildAreas(); this.rebuildAreas();
} }
}
if (isCompactMode) { if (isCompactMode) {
titlebar.prepend(topButtons); titlebar.prepend(topButtons);

View File

@@ -437,7 +437,7 @@
} }
} }
@media (-moz-bool-pref: 'zen.workspaces.show-workspace-indicator') or (not (-moz-bool-pref: 'zen.workspaces.enabled')) { @media (not (-moz-bool-pref: 'zen.workspaces.show-workspace-indicator')) or (not (-moz-bool-pref: 'zen.workspaces.enabled')) {
#zen-current-workspace-indicator { #zen-current-workspace-indicator {
display: none !important; display: none !important;
} }

View File

@@ -22,12 +22,16 @@ class ZenMultiWindowFeature {
return Services.wm.getMostRecentWindow('navigator:browser'); return Services.wm.getMostRecentWindow('navigator:browser');
} }
isActiveWindow() { static get isActiveWindow() {
return ZenMultiWindowFeature.currentBrowser === window; return ZenMultiWindowFeature.currentBrowser === window;
} }
windowIsActive(browser) {
return browser === ZenMultiWindowFeature.currentBrowser;
}
async foreachWindowAsActive(callback) { async foreachWindowAsActive(callback) {
if (!this.isActiveWindow()) { if (!ZenMultiWindowFeature.isActiveWindow) {
return; return;
} }
for (const browser of ZenMultiWindowFeature.browsers) { for (const browser of ZenMultiWindowFeature.browsers) {