From 463f2ebb21bb213e0254c0a47e92f68ccfb82ea4 Mon Sep 17 00:00:00 2001 From: Jason Kim Date: Sun, 15 Nov 2026 21:02:16 +0900 Subject: [PATCH 1/4] fix(macos): use monochrome tray icons with separated status glyphs --- src/system_tray.cpp | 24 +++++++++++++++---- src_assets/macos/tray/macos-tray-locked.svg | 18 ++++++++++++++ src_assets/macos/tray/macos-tray-pausing.svg | 20 ++++++++++++++++ src_assets/macos/tray/macos-tray-playing.svg | 18 ++++++++++++++ src_assets/macos/tray/macos-tray-sunshine.svg | 8 +++++++ tests/CMakeLists.txt | 9 +++++++ tests/unit/test_system_tray.cpp | 16 +++++++++++++ vite.config.js | 11 +++++++++ 8 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 src_assets/macos/tray/macos-tray-locked.svg create mode 100644 src_assets/macos/tray/macos-tray-pausing.svg create mode 100644 src_assets/macos/tray/macos-tray-playing.svg create mode 100644 src_assets/macos/tray/macos-tray-sunshine.svg diff --git a/src/system_tray.cpp b/src/system_tray.cpp index 8fcdf67caa3..290a8ace8f3 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -9,22 +9,38 @@ * @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. */ - #define TRAY_ICON_LOCKED WEB_DIR "images/sunshine-locked.svg" + #ifdef __APPLE__ + #define TRAY_ICON_LOCKED WEB_DIR "images/macos-tray-locked.svg" + #else + #define TRAY_ICON_LOCKED WEB_DIR "images/sunshine-locked.svg" + #endif /** * @def TRAY_ICON_VIRTUALHID * @brief Path to the Virtual HID Broker notification icon. diff --git a/src_assets/macos/tray/macos-tray-locked.svg b/src_assets/macos/tray/macos-tray-locked.svg new file mode 100644 index 00000000000..04d36a70006 --- /dev/null +++ b/src_assets/macos/tray/macos-tray-locked.svg @@ -0,0 +1,18 @@ + + + Sunshine macOS menu bar icon (locked) + + + + + + + + + + + + + + + diff --git a/src_assets/macos/tray/macos-tray-pausing.svg b/src_assets/macos/tray/macos-tray-pausing.svg new file mode 100644 index 00000000000..d1ebe2fb236 --- /dev/null +++ b/src_assets/macos/tray/macos-tray-pausing.svg @@ -0,0 +1,20 @@ + + + Sunshine macOS menu bar icon (pausing) + + + + + + + + + + + + + + + + + diff --git a/src_assets/macos/tray/macos-tray-playing.svg b/src_assets/macos/tray/macos-tray-playing.svg new file mode 100644 index 00000000000..a5bbe907cfb --- /dev/null +++ b/src_assets/macos/tray/macos-tray-playing.svg @@ -0,0 +1,18 @@ + + + Sunshine macOS menu bar icon (playing) + + + + + + + + + + + + + + + diff --git a/src_assets/macos/tray/macos-tray-sunshine.svg b/src_assets/macos/tray/macos-tray-sunshine.svg new file mode 100644 index 00000000000..4c2940df6b4 --- /dev/null +++ b/src_assets/macos/tray/macos-tray-sunshine.svg @@ -0,0 +1,8 @@ + + + Sunshine macOS menu bar icon + + + + + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fe24bb54e95..5678cec29e8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -139,6 +139,15 @@ if(SUNSHINE_ENABLE_TRAY AND (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Linux COPYONLY) endforeach() + if(APPLE) + foreach(icon IN ITEMS sunshine playing pausing locked) + configure_file( + "${CMAKE_SOURCE_DIR}/src_assets/macos/tray/macos-tray-${icon}.svg" + "${SUNSHINE_TRAY_TEST_ICON_DESTINATION_DIR}/macos-tray-${icon}.svg" + COPYONLY) + endforeach() + endif() + add_library(sunshine_tray_test_helpers STATIC ${CMAKE_SOURCE_DIR}/third-party/tray/tests/notification_utils.cpp ${CMAKE_SOURCE_DIR}/third-party/tray/tests/screenshot_utils.cpp) diff --git a/tests/unit/test_system_tray.cpp b/tests/unit/test_system_tray.cpp index c3043fd05a3..d430d69f690 100644 --- a/tests/unit/test_system_tray.cpp +++ b/tests/unit/test_system_tray.cpp @@ -351,6 +351,22 @@ TEST_F(SystemTrayTest, LeftClickUsesNativeMacOSMenu) { EXPECT_STREQ(tray_data.menu[0].text, "Open Sunshine"); EXPECT_FALSE(system_tray::tray_initialized_for_testing()); } + +TEST_F(SystemTrayTest, UsesMonochromeMacOSMenuBarIconsForEveryState) { + const auto &tray_data = system_tray::tray_data_for_testing(); + ASSERT_EQ(tray_data.iconPathCount, 5); + for (const auto *name : {"sunshine", "playing", "pausing", "locked"}) { + const std::string suffix = std::format("images/macos-tray-{}.svg", name); + bool found = false; + for (int index = 0; index < 4; ++index) { + if (std::string_view {tray_data.allIconPaths[index]}.ends_with(suffix)) { + found = true; + break; + } + } + EXPECT_TRUE(found) << "Missing macOS menu bar icon: " << suffix; + } +} #endif #ifdef _WIN32 diff --git a/vite.config.js b/vite.config.js index eb8ff036f27..898ba0ea321 100644 --- a/vite.config.js +++ b/vite.config.js @@ -42,6 +42,17 @@ const emitTrayIconsPlugin = { source: fs.readFileSync(resolve(projectRoot, 'sunshine.svg')), }); + if (process.platform === 'darwin') { + for (const name of ['sunshine', 'playing', 'pausing', 'locked']) { + const fileName = `macos-tray-${name}.svg`; + this.emitFile({ + type: 'asset', + fileName: `images/${fileName}`, + source: fs.readFileSync(resolve(projectRoot, 'src_assets/macos/tray', fileName)), + }); + } + } + const virtualHidIcon = resolve(projectRoot, 'third-party/libvirtualhid/libvirtualhid.svg'); if ((process.platform === 'win32' || process.platform === 'darwin') && fs.existsSync(virtualHidIcon)) { this.emitFile({ From c5132946097b3873985843253e9fe6a163df93ce Mon Sep 17 00:00:00 2001 From: Jason Kim Date: Mon, 16 Nov 2026 14:30:33 +0900 Subject: [PATCH 2/4] build(deps): bump third-party/tray for macOS template icon rendering --- third-party/tray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/tray b/third-party/tray index c1f2a8ab56d..ba93bc3be73 160000 --- a/third-party/tray +++ b/third-party/tray @@ -1 +1 @@ -Subproject commit c1f2a8ab56dd399b881fb7aeab4fe4fc9c58188d +Subproject commit ba93bc3be739bab9066ef78ac953802257416e7a From da541dada77f80849ad6dbea04203ea4059d8372 Mon Sep 17 00:00:00 2001 From: Jason Kim Date: Tue, 17 Nov 2026 13:31:34 +0900 Subject: [PATCH 3/4] fix(macos): opt in to menu bar template icons --- src/system_tray.cpp | 42 +++++++++++++++------ src_assets/macos/tray/macos-tray-locked.svg | 18 --------- tests/CMakeLists.txt | 2 +- tests/unit/test_system_tray.cpp | 37 ++++++++++++------ third-party/tray | 2 +- vite.config.js | 2 +- 6 files changed, 59 insertions(+), 44 deletions(-) delete mode 100644 src_assets/macos/tray/macos-tray-locked.svg diff --git a/src/system_tray.cpp b/src/system_tray.cpp index 290a8ace8f3..d41b4ecd2e2 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -34,13 +34,9 @@ #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. */ - #ifdef __APPLE__ - #define TRAY_ICON_LOCKED WEB_DIR "images/macos-tray-locked.svg" - #else - #define TRAY_ICON_LOCKED WEB_DIR "images/sunshine-locked.svg" - #endif + #define TRAY_ICON_LOCKED WEB_DIR "images/sunshine-locked.svg" /** * @def TRAY_ICON_VIRTUALHID * @brief Path to the Virtual HID Broker notification icon. @@ -691,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, + 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. */ @@ -809,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; } @@ -881,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); } @@ -903,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); } @@ -922,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; @@ -944,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"); diff --git a/src_assets/macos/tray/macos-tray-locked.svg b/src_assets/macos/tray/macos-tray-locked.svg deleted file mode 100644 index 04d36a70006..00000000000 --- a/src_assets/macos/tray/macos-tray-locked.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - Sunshine macOS menu bar icon (locked) - - - - - - - - - - - - - - - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5678cec29e8..94038408738 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -140,7 +140,7 @@ if(SUNSHINE_ENABLE_TRAY AND (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Linux endforeach() if(APPLE) - foreach(icon IN ITEMS sunshine playing pausing locked) + foreach(icon IN ITEMS sunshine playing pausing) configure_file( "${CMAKE_SOURCE_DIR}/src_assets/macos/tray/macos-tray-${icon}.svg" "${SUNSHINE_TRAY_TEST_ICON_DESTINATION_DIR}/macos-tray-${icon}.svg" diff --git a/tests/unit/test_system_tray.cpp b/tests/unit/test_system_tray.cpp index d430d69f690..cfe65c80df8 100644 --- a/tests/unit/test_system_tray.cpp +++ b/tests/unit/test_system_tray.cpp @@ -13,6 +13,7 @@ #endif // standard includes +#include #include #include #include @@ -213,8 +214,24 @@ namespace { EXPECT_STREQ(tray_data.tooltip, tooltip); EXPECT_STREQ(tray_data.notification_title, notification_title); EXPECT_STREQ(tray_data.notification_text, notification_text); + #ifdef __APPLE__ + EXPECT_EQ(tray_icon_is_template(), 1); + #endif if (notification_icon_index.has_value()) { + #ifdef __APPLE__ + constexpr std::array colored_icon_names { + "logo-sunshine.svg", + "sunshine-locked.svg", + "sunshine-playing.svg", + "sunshine-pausing.svg", + }; + ASSERT_NE(tray_data.notification_icon, nullptr); + const std::filesystem::path notification_icon {tray_data.notification_icon}; + EXPECT_EQ(notification_icon.filename(), colored_icon_names[*notification_icon_index]); + EXPECT_TRUE(std::filesystem::is_regular_file(notification_icon)); + #else EXPECT_STREQ(tray_data.notification_icon, tray_data.allIconPaths[*notification_icon_index]); + #endif } else { EXPECT_EQ(tray_data.notification_icon, nullptr); } @@ -352,20 +369,16 @@ TEST_F(SystemTrayTest, LeftClickUsesNativeMacOSMenu) { EXPECT_FALSE(system_tray::tray_initialized_for_testing()); } -TEST_F(SystemTrayTest, UsesMonochromeMacOSMenuBarIconsForEveryState) { +/** + * @brief Verify that the menu bar states use macOS artwork and pairing uses the colored lock. + */ +TEST_F(SystemTrayTest, UsesMonochromeMacOSMenuBarArtwork) { const auto &tray_data = system_tray::tray_data_for_testing(); ASSERT_EQ(tray_data.iconPathCount, 5); - for (const auto *name : {"sunshine", "playing", "pausing", "locked"}) { - const std::string suffix = std::format("images/macos-tray-{}.svg", name); - bool found = false; - for (int index = 0; index < 4; ++index) { - if (std::string_view {tray_data.allIconPaths[index]}.ends_with(suffix)) { - found = true; - break; - } - } - EXPECT_TRUE(found) << "Missing macOS menu bar icon: " << suffix; - } + EXPECT_EQ(std::filesystem::path {tray_data.allIconPaths[0]}.filename(), "macos-tray-sunshine.svg"); + EXPECT_EQ(std::filesystem::path {tray_data.allIconPaths[1]}.filename(), "sunshine-locked.svg"); + EXPECT_EQ(std::filesystem::path {tray_data.allIconPaths[2]}.filename(), "macos-tray-playing.svg"); + EXPECT_EQ(std::filesystem::path {tray_data.allIconPaths[3]}.filename(), "macos-tray-pausing.svg"); } #endif diff --git a/third-party/tray b/third-party/tray index ba93bc3be73..83f9b31b982 160000 --- a/third-party/tray +++ b/third-party/tray @@ -1 +1 @@ -Subproject commit ba93bc3be739bab9066ef78ac953802257416e7a +Subproject commit 83f9b31b98211b72e47d47211743b0fcdb52865f diff --git a/vite.config.js b/vite.config.js index 898ba0ea321..7bbeb71d421 100644 --- a/vite.config.js +++ b/vite.config.js @@ -43,7 +43,7 @@ const emitTrayIconsPlugin = { }); if (process.platform === 'darwin') { - for (const name of ['sunshine', 'playing', 'pausing', 'locked']) { + for (const name of ['sunshine', 'playing', 'pausing']) { const fileName = `macos-tray-${name}.svg`; this.emitFile({ type: 'asset', From 65cfee933bc116642863903a780f07cc33aef563 Mon Sep 17 00:00:00 2001 From: Jason Kim Date: Wed, 18 Nov 2026 12:01:20 +0900 Subject: [PATCH 4/4] build(deps): pin tray to merged template icon support --- third-party/tray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/tray b/third-party/tray index 83f9b31b982..c7b35bb6e3d 160000 --- a/third-party/tray +++ b/third-party/tray @@ -1 +1 @@ -Subproject commit 83f9b31b98211b72e47d47211743b0fcdb52865f +Subproject commit c7b35bb6e3d32b5ce03ce9ef14c25cc178927b2e