From 2f92c2c86971843cdf7c2148bc3b16657472028d Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Mon, 19 Jan 2026 02:19:06 +0100 Subject: [PATCH] feat: Add app menu and native menu items for new separate windows, b=no-bug, c=common, kbs --- .../browser/preferences/zen-preferences.ftl | 2 +- locales/en-US/browser/browser/zen-menubar.ftl | 5 ++- .../base/content/zen-keysets.inc.xhtml | 8 +--- src/browser/themes/shared/zen-icons/icons.css | 6 +-- src/zen/common/modules/ZenMenubar.mjs | 38 +++++++++++++++++-- src/zen/common/modules/ZenUIManager.mjs | 5 ++- src/zen/common/styles/zen-buttons.css | 2 + src/zen/kbs/ZenKeyboardShortcuts.mjs | 6 ++- src/zen/zen.globals.mjs | 1 + 9 files changed, 54 insertions(+), 19 deletions(-) diff --git a/locales/en-US/browser/browser/preferences/zen-preferences.ftl b/locales/en-US/browser/browser/preferences/zen-preferences.ftl index e4b18d637..b8a55d198 100644 --- a/locales/en-US/browser/browser/preferences/zen-preferences.ftl +++ b/locales/en-US/browser/browser/preferences/zen-preferences.ftl @@ -353,4 +353,4 @@ zen-devtools-toggle-storage-shortcut = Toggle Storage zen-devtools-toggle-dom-shortcut = Toggle DOM zen-devtools-toggle-accessibility-shortcut = Toggle Accessibility zen-close-all-unpinned-tabs-shortcut = Close All Unpinned Tabs -zen-new-unsynced-window-shortcut = New Unsynced Window +zen-new-unsynced-window-shortcut = New Separate Window diff --git a/locales/en-US/browser/browser/zen-menubar.ftl b/locales/en-US/browser/browser/zen-menubar.ftl index 6293e01a8..acbe09731 100644 --- a/locales/en-US/browser/browser/zen-menubar.ftl +++ b/locales/en-US/browser/browser/zen-menubar.ftl @@ -20,4 +20,7 @@ zen-menubar-appearance-auto = zen-menubar-appearance-light = .label = Light zen-menubar-appearance-dark = - .label = Dark \ No newline at end of file + .label = Dark + +zen-menubar-new-unsynced-window = + .label = New Separate Window \ No newline at end of file diff --git a/src/browser/base/content/zen-keysets.inc.xhtml b/src/browser/base/content/zen-keysets.inc.xhtml index 9844aa332..91d507cdf 100644 --- a/src/browser/base/content/zen-keysets.inc.xhtml +++ b/src/browser/base/content/zen-keysets.inc.xhtml @@ -4,10 +4,4 @@ #include zen-commands.inc.xhtml - -# Prefetch these keys because they are being used by the native menu bar -# and they need to be available even before the XUL is fully loaded and -# our KBS sysmtem is initialized. - - - + diff --git a/src/browser/themes/shared/zen-icons/icons.css b/src/browser/themes/shared/zen-icons/icons.css index 289e9527a..1e9792f05 100644 --- a/src/browser/themes/shared/zen-icons/icons.css +++ b/src/browser/themes/shared/zen-icons/icons.css @@ -239,8 +239,7 @@ list-style-image: url("privateBrowsing.svg") !important; } -#profiler-button-button > .toolbarbutton-icon, -.subviewbutton[label="Task Manager"] { +#profiler-button-button > .toolbarbutton-icon { list-style-image: url("tool-profiler.svg") !important; } @@ -249,7 +248,8 @@ } #new-window-button, -#appMenu-new-window-button2 { +#appMenu-new-window-button2, +#appMenu-new-zen-unsynced-window-button { list-style-image: url("window.svg") !important; } diff --git a/src/zen/common/modules/ZenMenubar.mjs b/src/zen/common/modules/ZenMenubar.mjs index b052c19a4..2f65b8d7b 100644 --- a/src/zen/common/modules/ZenMenubar.mjs +++ b/src/zen/common/modules/ZenMenubar.mjs @@ -9,10 +9,21 @@ const WINDOW_SCHEME_MAPPING = { auto: 2, }; -class nsZenMenuBar { - init() { +export class nsZenMenuBar { + constructor() { + window.addEventListener( + "ZenKeyboardShortcutsReady", + () => { + this.#init(); + }, + { once: true } + ); + } + + #init() { this.#initViewMenu(); this.#initSpacesMenu(); + this.#initAppMenu(); } #initViewMenu() { @@ -89,6 +100,25 @@ class nsZenMenuBar { gZenWorkspaces.updateWorkspacesChangeContextMenu(); }); } -} -export const ZenMenubar = new nsZenMenuBar(); + #initAppMenu() { + const openUnsyncedWindowItem = window.MozXULElement.parseXULToFragment( + `` + ).querySelector("toolbarbutton"); + PanelMultiView.getViewNode(document, "appMenu-new-window-button2").after( + openUnsyncedWindowItem + ); + document.getElementById("menu_newNavigator").after( + window.MozXULElement.parseXULToFragment(` + `) + ); + } +} diff --git a/src/zen/common/modules/ZenUIManager.mjs b/src/zen/common/modules/ZenUIManager.mjs index e22db2c56..c9f5d8c2f 100644 --- a/src/zen/common/modules/ZenUIManager.mjs +++ b/src/zen/common/modules/ZenUIManager.mjs @@ -3,7 +3,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. import { nsZenMultiWindowFeature } from "chrome://browser/content/zen-components/ZenCommonUtils.mjs"; -import { ZenMenubar } from "chrome://browser/content/zen-components/ZenMenubar.mjs"; +import { nsZenMenuBar } from "chrome://browser/content/zen-components/ZenMenubar.mjs"; window.gZenUIManager = { _popupTrackingElements: [], @@ -17,6 +17,8 @@ window.gZenUIManager = { _toastTimeouts: [], init() { + window.gZenMenubar = new nsZenMenuBar(); + document.addEventListener("popupshowing", this.onPopupShowing.bind(this)); document.addEventListener("popuphidden", this.onPopupHidden.bind(this)); @@ -63,7 +65,6 @@ window.gZenUIManager = { this._initOmnibox(); this._initBookmarkCollapseListener(); - ZenMenubar.init(); gURLBar._setPlaceholder(null); }, diff --git a/src/zen/common/styles/zen-buttons.css b/src/zen/common/styles/zen-buttons.css index 098f78f12..0c1f6afde 100644 --- a/src/zen/common/styles/zen-buttons.css +++ b/src/zen/common/styles/zen-buttons.css @@ -28,7 +28,9 @@ dialog::part(dialog-button) { border-color: light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.2)) !important; border-bottom-width: 2px !important; position: relative; +} +dialog[defaultButton="accept"]::part(dialog-button) { &:is([dlgtype="accept"], [dlgtype="cancel"]) { padding-inline-end: 3.7em; @media (-moz-platform: windows) { diff --git a/src/zen/kbs/ZenKeyboardShortcuts.mjs b/src/zen/kbs/ZenKeyboardShortcuts.mjs index 40d90baae..684e85976 100644 --- a/src/zen/kbs/ZenKeyboardShortcuts.mjs +++ b/src/zen/kbs/ZenKeyboardShortcuts.mjs @@ -875,6 +875,7 @@ class nsZenKeyboardShortcutsVersioner { return out; } + // eslint-disable-next-line complexity migrate(data, version) { if (version < 1) { // Migrate from 0 to 1 @@ -1111,7 +1112,9 @@ class nsZenKeyboardShortcutsVersioner { "N", "", ZEN_OTHER_SHORTCUTS_GROUP, - nsKeyShortcutModifiers.fromObject({ accel: true, alt: true }), + AppConstants.platform === "win" + ? nsKeyShortcutModifiers.fromObject({ alt: true }) + : nsKeyShortcutModifiers.fromObject({ accel: true, alt: true }), "cmd_zenNewNavigatorUnsynced", "zen-new-unsynced-window-shortcut" ) @@ -1162,6 +1165,7 @@ window.gZenKeyboardShortcutsManager = { this._applyShortcuts(); await this._saveShortcuts(); + window.dispatchEvent(new Event("ZenKeyboardShortcutsReady", { bubbles: true })); } }, diff --git a/src/zen/zen.globals.mjs b/src/zen/zen.globals.mjs index e1f18d43f..f082f84f1 100644 --- a/src/zen/zen.globals.mjs +++ b/src/zen/zen.globals.mjs @@ -18,6 +18,7 @@ export default [ "gZenUIManager", "gZenVerticalTabsManager", "gZenStartup", + "gZenMenubar", "gZenWorkspaces", "gZenKeyboardShortcutsManager",