feat(slint): macOS/Windows system tray (tray-icon) + macOS Dock policy

Add the NSStatusItem (macOS) / Shell_NotifyIcon (Windows) tray via the
tray-icon crate: the same 5-item menu, left-click window toggle, a themed
icon (auto uses a macOS template image that adapts to the menu bar), a
static QBZ tooltip, and live icon-variant switching. tray_icon::TrayIcon is
!Send and (on macOS) must be built on the main thread with NSApplication
running, so it lives in a thread_local created via invoke_from_event_loop;
its events are drained from a slint::Timer.

macOS close-to-tray reuses the cross-platform Slint hide/show path. The
opt-in Hide Dock icon toggle switches the NSApplication activation policy to
.accessory while closed to the menu bar (.regular by default, Spotify-style)
via objc2-app-kit.

cc
This commit is contained in:
vicrodh committed 2026-06-06 02:15:40 -06:00
1 parent 8a78c2250f
commit a91d629c2b
5 files changed
+850 -74

No files matched your search

+19
View File
@@ -67,5 +67,24 @@ qbz-credentials = { path = "../qbz-credentials" }
[target.'cfg(target_os = "linux")'.dependencies]
ksni = { version = "0.3", features = ["blocking"] }
# macOS (NSStatusItem) + Windows (Shell_NotifyIcon) tray via the tao team's
# tray-icon crate. Re-exports muda as tray_icon::menu. Windows is built but
# not shipped/tested.
[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
tray-icon = "0.24"
# macOS Dock-icon activation-policy toggle. Pinned to tray-icon's objc2 0.6 /
# app-kit 0.3 series (NOT winit's 0.5) so MainThreadMarker/NSApplication unify
# with tray-icon. setActivationPolicy is gated behind the NSRunningApplication
# feature.
[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.6"
objc2-app-kit = { version = "0.3", default-features = false, features = [
"std",
"NSApplication",
"NSResponder",
"NSRunningApplication",
] }
[build-dependencies]
slint-build = "1.16"