mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-11-30 09:08:53 +00:00
fix(macos): system tray left click menu
This commit is contained in:
1 parent
08131c5e27
commit
455c8a4910
2 files changed
+29
No files matched your search
@@ -291,10 +291,26 @@ namespace system_tray {
|
||||
static auto virtualhid_license_menu = initial_virtualhid_license_menu(); ///< Virtual HID Broker license submenu.
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
/**
|
||||
* @brief Leave macOS tray menu presentation to Qt's native status item.
|
||||
*
|
||||
* Qt opens an attached context menu on mouse press. Supplying a callback
|
||||
* prevents the tray library from opening a second popup on activation.
|
||||
*
|
||||
* @param tray_icon Tray icon that received the click.
|
||||
*/
|
||||
void tray_native_menu_click_cb([[maybe_unused]] struct tray *tray_icon) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Tray menu
|
||||
static struct tray tray = {
|
||||
.icon = TRAY_ICON,
|
||||
.tooltip = PROJECT_NAME,
|
||||
#ifdef __APPLE__
|
||||
.cb = tray_native_menu_click_cb,
|
||||
#endif
|
||||
.menu =
|
||||
(struct tray_menu[]) {
|
||||
// Tray menu labels currently use the project's English source strings.
|
||||
|
||||
@@ -339,6 +339,19 @@ TEST_F(SystemTrayTest, UpdatesAreIgnoredBeforeInitialization) {
|
||||
EXPECT_EQ(system_tray::end_tray(), 0);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
TEST_F(SystemTrayTest, LeftClickUsesNativeMacOSMenu) {
|
||||
const auto &tray_data = system_tray::tray_data_for_testing();
|
||||
ASSERT_NE(tray_data.cb, nullptr);
|
||||
ASSERT_NE(tray_data.menu, nullptr);
|
||||
|
||||
tray_data.cb(nullptr);
|
||||
|
||||
EXPECT_STREQ(tray_data.menu[0].text, "Open Sunshine");
|
||||
EXPECT_FALSE(system_tray::tray_initialized_for_testing());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
TEST_F(SystemTrayTest, ResolvesDevelopmentTrayIconsFromExecutableDirectory) {
|
||||
EXPECT_EQ(system_tray::resource_path_for_testing(nullptr), nullptr);
|
||||
|
||||
Reference in new issue
Block a user