From ef3656811862fa508e62285cf7bde0fb3a657813 Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 5 Oct 2026 20:19:52 +0800 Subject: [PATCH] Menu bar: the menu follows the in-app appearance, not the menu bar's tint On macOS 26 the menu bar is transparent and takes its light or dark tint from the wallpaper, so in Dark Mode with a bright wallpaper the menu opened light. The menu now takes NSApp's effective appearance: the appearance chosen in Settings, or the system's mode when set to follow the system. The bar's own two lines still follow the menu bar so they stay legible. Co-Authored-By: Claude Opus 5.5 --- src-tauri/src/menubar/macos.rs | 9 ++++----- src-tauri/src/theme.rs | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/menubar/macos.rs b/src-tauri/src/menubar/macos.rs index 6cf0b64e..64bf8676 100644 --- a/src-tauri/src/menubar/macos.rs +++ b/src-tauri/src/menubar/macos.rs @@ -1119,12 +1119,11 @@ define_class!( unsafe impl NSMenuDelegate for Target { #[unsafe(method(menuWillOpen:))] fn menu_will_open(&self, menu: &NSMenu) { - // **菜单跟菜单栏的深浅走**,不跟应用内选的外观 —— 和系统其他菜单栏菜单一样 + // **菜单跟应用内选的外观走**(跟随系统时就是系统的深浅模式),不跟菜单栏 + // —— macOS 26 的菜单栏透明,深浅随壁纸变:深色模式配亮壁纸时它是浅的。 + // 显式设上,不留给 AppKit 去推断状态栏菜单该继承谁 let mtm = MainThreadMarker::from(self); - let bar = UI.with(|ui| ui.borrow().as_ref().and_then(|ui| ui.item.button(mtm))); - if let Some(button) = bar { - menu.setAppearance(Some(&button.effectiveAppearance())); - } + menu.setAppearance(Some(&NSApplication::sharedApplication(mtm).effectiveAppearance())); OPEN.with(|o| o.set(true)); if let Some(f) = ON_OPEN.with(|o| o.borrow().clone()) { f(true); diff --git a/src-tauri/src/theme.rs b/src-tauri/src/theme.rs index 6ba82b0f..2fd51990 100644 --- a/src-tauri/src/theme.rs +++ b/src-tauri/src/theme.rs @@ -11,7 +11,8 @@ //! //! 代价是它在 macOS 上是应用级的(Tauri 的 `set_theme` 文档写明了),不是 //! 单个窗口的 —— 对一个只有一个窗口的应用来说,正是想要的那个范围。菜单栏 -//! 上那个图标不受影响:它是模板图,靠 alpha 跟随菜单栏自己的亮暗。 +//! 点开的那份菜单也跟着它(`menubar::macos` 打开时设上);菜单栏上那个图标 +//! 不受影响:它是模板图,靠 alpha 跟随菜单栏自己的亮暗。 //! //! **Linux 上换的是 GTK 的 `gtk-application-prefer-dark-theme`。**tao 的 //! `set_theme` 写的就是这一项(进程级),WebKitGTK 按它定