Skip to content

Commit

Permalink
Don't update tray icon after tray_exit() was called
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman authored and ReenigneArcher committed Mar 13, 2024
1 parent 22736c4 commit c43dd24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- (Linux) Fix udev rules for uinput access not working until after reboot
- (Linux) Fix wrong path in desktop files
- (Tray) Cache icons to avoid possible DRM issues
- (Tray) Fix attempt to update tray icon after it was destroyed
- (Linux) Migrate old config files to new location if env SUNSHINE_MIGRATE_CONFIG=1 is set (automatically set for Flatpak)
- (Linux/Fedora) Re-enable CUDA support and bump to 12.4.0

Expand Down
20 changes: 20 additions & 0 deletions src/system_tray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ using namespace std::literals;

// system_tray namespace
namespace system_tray {
static std::atomic<bool> tray_initialized = false;

/**
* @brief Callback for opening the UI from the system tray.
* @param item The tray menu item.
Expand Down Expand Up @@ -239,6 +241,7 @@ namespace system_tray {
BOOST_LOG(info) << "System tray created"sv;
}

tray_initialized = true;
while (tray_loop(1) == 0) {
BOOST_LOG(debug) << "System tray loop"sv;
}
Expand Down Expand Up @@ -275,6 +278,7 @@ namespace system_tray {
*/
int
end_tray() {
tray_initialized = false;
tray_exit();
return 0;
}
Expand All @@ -285,6 +289,10 @@ namespace system_tray {
*/
void
update_tray_playing(std::string app_name) {
if (!tray_initialized) {
return;
}

tray.notification_title = NULL;
tray.notification_text = NULL;
tray.notification_cb = NULL;
Expand All @@ -307,6 +315,10 @@ namespace system_tray {
*/
void
update_tray_pausing(std::string app_name) {
if (!tray_initialized) {
return;
}

tray.notification_title = NULL;
tray.notification_text = NULL;
tray.notification_cb = NULL;
Expand All @@ -329,6 +341,10 @@ namespace system_tray {
*/
void
update_tray_stopped(std::string app_name) {
if (!tray_initialized) {
return;
}

tray.notification_title = NULL;
tray.notification_text = NULL;
tray.notification_cb = NULL;
Expand All @@ -350,6 +366,10 @@ namespace system_tray {
*/
void
update_tray_require_pin() {
if (!tray_initialized) {
return;
}

tray.notification_title = NULL;
tray.notification_text = NULL;
tray.notification_cb = NULL;
Expand Down

0 comments on commit c43dd24

Please sign in to comment.