Menu ▾ ▴

#185 Windows: monochrome tray icon option (taskbar-theme aware)

closed
nobody
2026-08-28
2026-07-22
Anonymous
No

Originally created by: kristofferR

Third platform for the shared tray_icon_style: "color" | "symbolic" setting (Linux [#169], macOS [#178] — Ref [#169], Ref [#178]). Depends on whichever lands first (setting + shared carrier-symbolic.png asset); this issue adds only the Windows branch. The Settings row's platform gate widens to include Windows.

Key verified gotcha: the tray sits on the taskbar, governed by SystemUsesLightTheme — but the dark-light crate (used by window.rs::system_prefers_dark) reads AppsUseLightTheme. The two diverge under Windows 11 "Custom" color mode, so the existing helper must NOT be reused.

  • Theme detection: add Win32_System_Registry to the existing windows-sys features (feature flag, no new crate). New taskbar_prefers_dark() -> bool reading HKCU\...\Themes\Personalize\SystemUsesLightTheme via RegGetValueW; missing value/error → dark (the value is absent on old Win10 builds where the taskbar was always dark). Pure dark_taskbar_from_reg(Option<u32>) -> bool for tests.
  • Tinting: pure tint_symbolic(rgba, dark_taskbar) — white glyph as-is on a dark taskbar, RGB recolored to ~#404040 (alpha preserved) on a light one. Asset decode failure → fall back to the color icon (never an invisible tray).
  • Application points: a tray_base_image(app, settings) helper used by build_tray_with_menu's .icon(...) (fresh trays correct immediately) and by apply_settings via tray.set_icon when the cached (style, dark) pair changes (no flicker on every save). This is the same live-toggle path [#178] needs — write it platform-agnostically with a per-platform image pick.
  • Live-ish refresh: tao's ThemeChanged tracks the apps theme, not the taskbar theme, so no watcher in v1. Two triggers suffice: apply_settings, plus a cheap re-check piggybacked on the carrier:unread listener (fires at least every ~60 s from the page poll) — a taskbar-theme flip retints within a minute. RegNotifyChangeKeyValue noted as a follow-up.

Testing. Unit: dark_taskbar_from_reg (None→dark, 1→light, 0→dark); tint_symbolic both branches; style selection falls back to color on unknown. Manual (Win11): Dark → white glyph; Light → dark-gray glyph; Custom (Windows mode Light, app mode Dark) → glyph follows Windows mode — the case dark-light would get wrong; live toggle both directions; theme flip retints within ~1 min.

Part of [#187].

Related

Tickets: #169
Tickets: #178
Tickets: #187
Tickets: #233
Tickets: #247

Discussion

  • Anonymous

    Anonymous - 2026-08-28

    Originally posted by: kristofferR

    Completed and manually verified through PR [#247]. Windows now renders a crisp taskbar-sized monochrome icon, follows taskbar theme and DPI changes live, and updates tray resources without the deadlocks found during stress testing. Closing as complete.

     

    Related

    Tickets: #247

  • Anonymous

    Anonymous - 2026-08-28

    Ticket changed by: kristofferR

    • status: open --> closed
     

Log in to post a comment.