Repository navigation
fix(macos): use monochrome menu bar icons with clear status glyphs #6107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
463f2eb
c513294
da541da
65cfee9
f87f1e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,20 +9,32 @@ | |
| * @def TRAY_ICON | ||
| * @brief Path to the default system tray icon. | ||
| */ | ||
| #define TRAY_ICON WEB_DIR "images/logo-sunshine.svg" | ||
| #ifdef __APPLE__ | ||
| #define TRAY_ICON WEB_DIR "images/macos-tray-sunshine.svg" | ||
| #else | ||
| #define TRAY_ICON WEB_DIR "images/logo-sunshine.svg" | ||
| #endif | ||
| /** | ||
| * @def TRAY_ICON_PLAYING | ||
| * @brief Path to the system tray icon used while streaming. | ||
| */ | ||
| #define TRAY_ICON_PLAYING WEB_DIR "images/sunshine-playing.svg" | ||
| #ifdef __APPLE__ | ||
| #define TRAY_ICON_PLAYING WEB_DIR "images/macos-tray-playing.svg" | ||
| #else | ||
| #define TRAY_ICON_PLAYING WEB_DIR "images/sunshine-playing.svg" | ||
| #endif | ||
| /** | ||
| * @def TRAY_ICON_PAUSING | ||
| * @brief Path to the system tray icon used while streaming is paused. | ||
| */ | ||
| #define TRAY_ICON_PAUSING WEB_DIR "images/sunshine-pausing.svg" | ||
| #ifdef __APPLE__ | ||
| #define TRAY_ICON_PAUSING WEB_DIR "images/macos-tray-pausing.svg" | ||
| #else | ||
| #define TRAY_ICON_PAUSING WEB_DIR "images/sunshine-pausing.svg" | ||
| #endif | ||
| /** | ||
| * @def TRAY_ICON_LOCKED | ||
| * @brief Path to the system tray icon used for pairing requests. | ||
| * @brief Path to the notification icon used for pairing requests. | ||
| */ | ||
| #define TRAY_ICON_LOCKED WEB_DIR "images/sunshine-locked.svg" | ||
| /** | ||
|
|
@@ -675,6 +687,25 @@ namespace system_tray { | |
| #endif | ||
| } | ||
|
|
||
| /** | ||
| * @brief Get the colored artwork for a tray state notification. | ||
| * @param icon_index Index of the state in the tray icon paths. | ||
| * @return Path to the notification artwork. | ||
| */ | ||
| static const char *notification_icon_path(const std::size_t icon_index) { | ||
| #ifdef __APPLE__ | ||
| constexpr std::array notification_icons { | ||
| WEB_DIR "images/logo-sunshine.svg", | ||
| TRAY_ICON_LOCKED, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this one icon doesn't have a macOS version?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! appears to be used only for the system notification popup when a pairing request arrives, rather than as a menu bar icon. Since it's used for notifications, the existing colored artwork remains highly visible and doesn't suffer from the contrast issues we see on the menu bar. Given the goal of this PR was specifically to improve the menu bar icon visibility using template rendering, I omitted this one. Would you prefer I add a monochrome version for this notification icon as well to maintain consistency?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. We should probably add the monochrome version with this PR just in case we decide to use it in the tray in the future.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I agree that keeping it consistent is better for future-proofing. I'll add the monochrome version of the locked icon in this PR and update the macOS pathing accordingly. |
||
| WEB_DIR "images/sunshine-playing.svg", | ||
| WEB_DIR "images/sunshine-pausing.svg", | ||
| }; | ||
| return GetResourcePath(notification_icons[icon_index]); | ||
| #else | ||
| return tray.allIconPaths[icon_index]; | ||
| #endif | ||
| } | ||
|
|
||
| /** | ||
| * @brief Resolve tray icons against the current executable or application bundle. | ||
| */ | ||
|
|
@@ -793,7 +824,12 @@ namespace system_tray { | |
| if (stop_token.stop_requested()) { | ||
| return 1; | ||
| } | ||
| if (tray_init(&tray) < 0) { | ||
| #ifdef __APPLE__ | ||
| const int result = tray_init_with_options(&tray, TRAY_OPTION_TEMPLATE_ICON); | ||
| #else | ||
| const int result = tray_init(&tray); | ||
| #endif | ||
| if (result < 0) { | ||
| BOOST_LOG(warning) << "Failed to create system tray"sv; | ||
| return 1; | ||
| } | ||
|
|
@@ -865,7 +901,7 @@ namespace system_tray { | |
| static std::string msg = std::format("Streaming started for {}", app_name); | ||
| tray.notification_text = msg.c_str(); | ||
| tray.tooltip = msg.c_str(); | ||
| tray.notification_icon = tray.allIconPaths[2]; | ||
| tray.notification_icon = notification_icon_path(2); | ||
| tray_update(&tray); | ||
| } | ||
|
|
||
|
|
@@ -887,7 +923,7 @@ namespace system_tray { | |
| tray.notification_title = "Stream Paused"; | ||
| tray.notification_text = msg.c_str(); | ||
| tray.tooltip = msg.c_str(); | ||
| tray.notification_icon = tray.allIconPaths[3]; | ||
| tray.notification_icon = notification_icon_path(3); | ||
| tray_update(&tray); | ||
| } | ||
|
|
||
|
|
@@ -906,7 +942,7 @@ namespace system_tray { | |
|
|
||
| static std::string msg = std::format("Application {} successfully stopped", app_name); | ||
| tray.icon = tray.allIconPaths[0]; | ||
| tray.notification_icon = tray.allIconPaths[0]; | ||
| tray.notification_icon = notification_icon_path(0); | ||
| tray.notification_title = "Application Stopped"; | ||
| tray.notification_text = msg.c_str(); | ||
| tray.tooltip = PROJECT_NAME; | ||
|
|
@@ -928,7 +964,7 @@ namespace system_tray { | |
| tray.icon = tray.allIconPaths[0]; | ||
| tray.notification_title = "Incoming Pairing Request"; | ||
| tray.notification_text = "Click here to complete the pairing process"; | ||
| tray.notification_icon = tray.allIconPaths[1]; | ||
| tray.notification_icon = notification_icon_path(1); | ||
| tray.tooltip = PROJECT_NAME; | ||
| tray.notification_cb = []() { | ||
| launch_ui("/pin"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Enable macOS template rendering before selecting white-only icons
On a light menu bar (for example, Light appearance with Reduce Transparency enabled), this unconditionally replaces the visible colored icon with white artwork. The pinned tray backend's
QtTrayMenu::lookupIcon()returns an ordinaryQIconand never callssetIsMask(true). Qt's Cocoa tray implementation sets the native image's template flag fromicon.isMask(), so AppKit keeps these icons white. All four SVGs producedisMask=falseand exclusively white visible pixels in a Qt 6.11.2 probe; compositing them over a light background leaves almost no contrast. The limitation noted in the PR description therefore regresses icon and streaming-state visibility for light-menu-bar users.Please ship template handling together with this asset switch, covering both tray initialization and updates. For example, this scoped change in the file-backed branch of
QtTrayMenu::lookupIcon()inthird-party/tray/src/QtTrayMenu.cppmarks these assets as templates:A tray dependency change also needs the corresponding submodule revision update here. The flag-setting expression was compiled and verified in the focused Qt probe; the full Sunshine application was not built. Please validate light and dark menu bars after initialization and after a streaming-state change; the new path-string test cannot catch this rendering regression.
Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed guidance!
result.setIsMask(true)formacos-tray-*assets.third-party/traysubmodule revision in this PR has been updated to point to that commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rechecked at
c5132946. The updated gitlink points to trayba93bc3b(LizardByte/tray#218), wherelookupIcon()setsisMaskfor the macOS-specific filenames before both initial tray construction and subsequent icon updates. That addresses the missing-template mechanism identified here. I also inspected the eight supplied screenshots: all four states are visible as dark icons on the light background and white icons on the darker background.My independent checks: all 217 web tests passed, the Linux web build passed, and
git diff --checkpassed for this revision. The added native test checks the four selected asset paths; it does not itself verify Cocoa template rendering. I don't have a macOS environment here, so the live appearance/state-transition evidence remains the contributor's testing, not an independent native validation.Please merge the tray dependency first and, if its merged commit differs (for example after squash), update this gitlink to that upstream commit. CI, lint and CodeQL for both current heads still await workflow approval. I found no additional concrete blocker in this focused re-review.
Review completed by Codex | Model: unavailable | Thinking: unavailable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correction to my proposed implementation and follow-up: the contrast problem is real, but I was too prescriptive in suggesting a Sunshine filename-prefix rule inside the shared tray library, and then asking for that dependency to be merged. Please don't treat that particular library change as required by this review.
Tray #218 does not force template rendering for every consumer: it affects only file-backed icons on macOS whose basename starts with
macos-tray-. However, that still makes Sunshine's asset naming convention shared-library policy, and the same lookup function also handles notification icons. The existing tray API doesn't expose a template flag for Sunshine to set directly.The requirement here is to preserve icon/state visibility on both light and dark menu bars, not to mandate a dependency feature. Retaining the existing artwork avoids introducing this regression without changing tray. If adaptive monochrome artwork is retained, an explicit opt-in with unchanged defaults for other consumers is one possible design, subject to the tray maintainer's agreement, rather than a required scope expansion. My prior verification establishes the current fix's mechanism and the supplied screenshots' contrast, not that its shared-library API design should be accepted.
Review completed by Codex | Model: unavailable | Thinking: unavailable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened LizardByte/tray#219 for the explicit opt-in and updated this PR to use it on the macOS menu bar. The new regression checks cover the active template flag after initialization and state changes, along with colored notification artwork.