Skip to content

fix(macos): use monochrome menu bar icons with clear status glyphs - #6107

Open
kjm0202 wants to merge 5 commits into
SunshineStream:masterfrom
kjm0202:fix/macos-monochrome-tray-icons
Open

kjm0202 wants to merge 5 commits into
SunshineStream:masterfrom
kjm0202:fix/macos-monochrome-tray-icons

Conversation

@kjm0202

@kjm0202 kjm0202 commented Nov 15, 2026 •

Copy link
Copy Markdown

Description

Use native template rendering for Sunshine's idle, streaming, paused, and pairing menu bar icons on macOS so the artwork adapts to light and dark backgrounds. Sunshine requests TRAY_OPTION_TEMPLATE_ICON when it initializes the tray, and tray applies the option on each icon update.

Pairing notifications use the existing colored artwork. A pairing request shows the colored lock in its notification and uses the idle artwork in the menu bar.

The third-party/tray submodule is pinned to c7b35bb6e3d32b5ce03ce9ef14c25cc178927b2e on upstream master, which includes the merged opt-in API from LizardByte/tray#219.

Screenshot

These captures show the same three template assets in the earlier prototype.

Menu bar state Light background Dark background
Idle Idle on a light menu bar Idle on a dark menu bar
Streaming Streaming on a light menu bar Streaming on a dark menu bar
Paused Paused on a light menu bar Paused on a dark menu bar
Pairing Pairing on a light menu bar Pairing on a dark menu bar

Issues Fixed or Closed

Roadmap Issues

Testing

  • Built Sunshine and test_sunshine with macOS SDK 27.2 and Qt 6.12.0.
  • test_sunshine passed 844 tests with 8 environment-dependent skips. The 11 macOS tray tests passed, including the state transition and screenshot tests. The state transition checks verify the active tray icon's template flag and the colored notification artwork.
  • npm test passed 217 tests. The web build emitted the three macOS menu bar SVGs, and their bundled copies match the sources.
  • CMake lint and git diff --check passed.
  • Rechecked the merged tray revision with the Sunshine build and all 11 macOS tray tests. Its file tree matches the previously tested review commit.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the light-menu-bar visibility regression described inline.

Validation: npm ci --ignore-scripts, npm run build, and all 217 web tests passed with the PR's locked dependencies. All four emitted macOS SVGs match their sources. XML parsing, ClangFormat, CMake lint with the shared workflow's options, and git diff --check passed. A focused Qt 6.11.2 probe confirmed that the four icons load successfully but remain white, non-template images.

Verification limits: the full native Sunshine build and test_sunshine suite were not run. CI, common lint, and CodeQL workflows await maintainer approval. The head was rechecked at 463f2ebb21bb213e0254c0a47e92f68ccfb82ea4; GitHub reports it mergeable, and the latest target retains the original colored-icon behavior.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Comment thread src/system_tray.cpp
*/
#define TRAY_ICON WEB_DIR "images/logo-sunshine.svg"
#ifdef __APPLE__
#define TRAY_ICON WEB_DIR "images/macos-tray-sunshine.svg"

Copy link
Copy Markdown
Member

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 ordinary QIcon and never calls setIsMask(true). Qt's Cocoa tray implementation sets the native image's template flag from icon.isMask(), so AppKit keeps these icons white. All four SVGs produced isMask=false and 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() in third-party/tray/src/QtTrayMenu.cpp marks these assets as templates:

    if (auto result = QIcon(icon); !result.isNull()) {
#if defined(__APPLE__)
      if (icon.section('/', -1).startsWith("macos-tray-")) {
        result.setIsMask(true);
      }
#endif
      return result;
    }

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

Copy link
Copy Markdown
Author

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!

  • Template image handling has been submitted to LizardByte/tray in fix(macos): enable template rendering for monochrome tray icons LizardByte/tray#218, adding result.setIsMask(true) for macos-tray-* assets.
  • The third-party/tray submodule revision in this PR has been updated to point to that commit.
  • Verified on macOS that all four states (idle, streaming, paused, pairing) render in dark/black with crisp contrast on light/white menu bars and in white on dark menu bars. Individual screenshots for both light and dark appearances have been added to the updated PR description using the official template.

Copy link
Copy Markdown
Member

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 tray ba93bc3b (LizardByte/tray#218), where lookupIcon() sets isMask for 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 --check passed 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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown
Member

Please update the PR description to use the SunshineStream organization PR template. Preserve all sections and HTML comments, including Type of Change, Checklist, and AI Usage, and complete the applicable fields. Since this changes the menu bar UI, please include screenshots in the Screenshot section. Your existing summary and validation details can go under Description and Testing; sections that do not apply may remain empty and their boxes unchecked.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Copy link
Copy Markdown
Member

@kjm0202 Now that LizardByte/tray#219 has merged, could you please update the third-party/tray submodule to the latest commit on tray's master branch? Thanks!

@kjm0202

kjm0202 commented Nov 18, 2026

Copy link
Copy Markdown
Author

Updated third-party/tray to the latest upstream master commit, c7b35bb6e3d32b5ce03ce9ef14c25cc178927b2e, in 65cfee93. The Sunshine build and all 11 macOS tray tests pass with this revision. The PR description now references the merged dependency.

Comment thread src/system_tray.cpp
#ifdef __APPLE__
constexpr std::array notification_icons {
WEB_DIR "images/logo-sunshine.svg",
TRAY_ICON_LOCKED,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this one icon doesn't have a macOS version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants