feat(qt): wire the macOS Hide-Dock setting — Spotify behaviour on close

The row rendered, persisted and drove nothing, which is the exact defect
class the miniplayer/tray contract existed to end. The owner named the
behaviour they want: close puts the app in the menu bar AND drops the Dock
icon; minimize still goes to the Dock like any app.

So only the CLOSE path touches the policy. The wiring point is
`QbzTray.setWindowShown`, which QML calls from exactly two places —
`hideToTray` and `showFromTray` — so this needs no third visibility owner and
cannot drift from the real window state.

Hiding drops the icon only when the setting is on; SHOWING always restores
it, with no setting check. A user who turns the option off while the app sits
in the menu bar must still get their icon back, and restoring an icon that is
already there costs nothing.

NOT COMPILED AND NOT TESTED. This tree builds on Linux, the arm is behind
cfg(target_os = "macos"), and a cross-check dies in the C build scripts for
want of an Apple SDK. So the API was verified by READING objc2-app-kit 0.2.2
instead — which immediately earned its keep: `NSApplicationActivationPolicy`
lives in NSRunningApplication.rs, not NSApplication.rs, and the NSApplication
feature does not pull it. The three features here match the reference's own
proven set. First real check is a build on the Mac mini.

cc
This commit is contained in:
vicrodh committed 2026-08-04 14:55:36 -06:00
1 parent 8bc32a91a3
commit dc604bdf62
4 files changed
+91

No files matched your search

+32
View File
@@ -157,3 +157,35 @@ ksni = { version = "0.3", default-features = false, features = ["blocking", "asy
[build-dependencies]
cxx-qt-build = "0.7"
# macOS only: the Dock-icon activation policy behind the "Hide Dock icon when
# closed to menu bar" setting (Spotify behaviour — close puts the app in the
# menu bar and drops the Dock icon; minimize still goes to the Dock).
#
# objc2 0.5 / objc2-app-kit 0.2 are pinned to the SAME generation the Slint
# crate uses (crates/qbz/Cargo.toml:166-172). That matters even though this
# crate has no winit: mixing objc2 generations in one binary registers
# duplicate objc classes, which is the failure the reference documents at
# length. Only the two items `set_mac_dock_hidden` names are enabled.
#
# ⚠ NOT COMPILED OR TESTED HERE. This tree builds on Linux; the macOS arm is
# behind cfg, so `cargo build` cannot see it. First real check is a macOS
# build — the Mac mini (192.168.0.69) is where that happens.
[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.5"
objc2-app-kit = { version = "0.2", default-features = false, features = [
"std",
# NSApplication: the class and `setActivationPolicy`.
"NSApplication",
# NSResponder: `sharedApplication` is behind `cfg(feature = "NSResponder")`
# (objc2-app-kit-0.2.2/src/generated/NSApplication.rs:326-329) — it is
# NSApplication's superclass, and the NSApplication feature does NOT pull
# it.
"NSResponder",
# NSRunningApplication: where `NSApplicationActivationPolicy` actually
# lives (…/src/generated/NSRunningApplication.rs:33-35), NOT in
# NSApplication.rs as the name suggests. Verified by reading the crate
# rather than by compiling — this arm cannot be built on Linux, and the
# reference's own proven set (crates/qbz/Cargo.toml) lists the same three.
"NSRunningApplication",
] }