Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
system_tray.cpp File Reference

Definitions for the system tray icon and notification system. More...

#include <AccCtrl.h>
#include <AclAPI.h>
#include <array>
#include <atomic>
#include <chrono>
#include <csignal>
#include <cstddef>
#include <filesystem>
#include <format>
#include <functional>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
#include <system_error>
#include <thread>
#include <unordered_map>
#include <utility>
#include <boost/filesystem.hpp>
#include <tray.h>
#include <libvirtualhid/license.hpp>
#include "config.h"
#include "confighttp.h"
#include "display_device.h"
#include "logging.h"
#include "platform/common.h"
#include "process.h"
#include "src/entry_handler.h"
#include "string_hash.h"
#include "system_tray.h"
#include "thread_safe.h"
#include "platform/windows/utf_utils.h"
Include dependency graph for system_tray.cpp:

Namespaces

namespace  system_tray
 Handles the system tray icon and notification system.

Macros

#define TRAY_ICON   WEB_DIR "images/logo-sunshine.svg"
 Path to the default system tray icon.
#define TRAY_ICON_LOCKED   WEB_DIR "images/sunshine-locked.svg"
 Path to the system tray icon used for pairing requests.
#define TRAY_ICON_PAUSING   WEB_DIR "images/sunshine-pausing.svg"
 Path to the system tray icon used while streaming is paused.
#define TRAY_ICON_PLAYING   WEB_DIR "images/sunshine-playing.svg"
 Path to the system tray icon used while streaming.
#define TRAY_ICON_VIRTUALHID   WEB_DIR "images/logo-libvirtualhid.svg"
 Path to the Virtual HID Broker notification icon.
#define WIN32_LEAN_AND_MEAN
 Macro for WIN32 LEAN AND MEAN.

Functions

void system_tray::clear_tray_notification ()
 Clear notification fields before replacing the tray state.
int system_tray::end_tray ()
 Exit the system tray.
const char * system_tray::GetResourcePath (const char *relativePath)
 Get resource path.
int system_tray::init_tray ()
 Initializes the system tray without starting a loop.
int system_tray::init_tray_threaded ()
 Initializes and runs the system tray in a separate thread.
int system_tray::init_tray_with_stop_token (const std::stop_token stop_token)
 Initialize the tray, optionally observing an owning thread's stop request.
std::array< struct tray_menu, 9 > system_tray::initial_virtualhid_license_menu ()
 Create the initial Virtual HID Broker license submenu.
void system_tray::prepare_tray_virtualhid_driver ()
 Query the Virtual HID Broker version and prepare its startup notification.
void system_tray::prepare_tray_virtualhid_license ()
 Query the Virtual HID Broker license and prepare the startup tray state.
int system_tray::process_tray_events ()
 Processes a single tray event iteration.
void system_tray::rebuild_virtualhid_license_menu (const lvh::LicenseStatus &license)
 Rebuild the Virtual HID Broker submenu for the latest license state.
void system_tray::resolve_tray_icon_paths ()
 Resolve tray icons against the current executable or application bundle.
void system_tray::run_tray_until_exit (const std::shared_ptr< safe::event_t< bool > > &shutdown_event)
 Process tray events until exit and notify the application's workers.
template<typename Callback = std::nullptr_t>
void system_tray::set_virtualhid_license_menu_item (const std::size_t index, std::string text, const bool disabled, Callback callback=nullptr)
 Assign text and behavior to one Virtual HID Broker submenu item.
void system_tray::tray_donate_github_cb (struct tray_menu *item)
 Callback for opening GitHub Sponsors from the system tray.
void system_tray::tray_donate_patreon_cb (struct tray_menu *item)
 Callback for opening Patreon from the system tray.
void system_tray::tray_donate_paypal_cb (struct tray_menu *item)
 Callback for opening PayPal donation from the system tray.
void system_tray::tray_native_menu_click_cb (struct tray *tray_icon)
 Leave macOS tray menu presentation to Qt's native status item.
void system_tray::tray_open_ui_cb (struct tray_menu *item)
 Callback for opening the UI from the system tray.
void system_tray::tray_quit_cb (struct tray_menu *item)
 Callback for exiting Sunshine from the system tray.
void system_tray::tray_reset_display_device_config_cb (struct tray_menu *item)
 Callback for resetting display device configuration.
void system_tray::tray_restart_cb (struct tray_menu *item)
 Callback for restarting Sunshine from the system tray.
void system_tray::tray_virtualhid_download_cb (struct tray_menu *item)
 Callback for opening the latest Virtual HID Broker release.
void system_tray::tray_virtualhid_license_cb (struct tray_menu *item)
 Callback for opening Virtual HID Broker license settings in the Web UI.
void system_tray::update_tray_pausing (std::string app_name)
 Sets the tray icon in pausing mode (stream stopped but app running) and spawns the appropriate notification.
void system_tray::update_tray_playing (std::string app_name)
 Sets the tray icon in playing mode and spawns the appropriate notification.
void system_tray::update_tray_require_pin ()
 Spawns a notification for PIN Pairing. Clicking it opens the PIN Web UI Page.
void system_tray::update_tray_stopped (std::string app_name)
 Sets the tray icon in stopped mode (app and stream stopped) and spawns the appropriate notification.
void system_tray::update_tray_virtualhid_driver (bool installed, std::string_view version, bool version_compatible, std::string_view supported_versions)
 Show an update notification for an unsupported Virtual HID Broker.
void system_tray::update_tray_virtualhid_license (const lvh::LicenseStatus &license, bool notify_if_unlicensed)
 Update the Virtual HID Broker license submenu and optional notification.
std::string_view system_tray::virtualhid_license_state_detail (lvh::LicenseState state)
 Return explanatory tray text for a non-active license state.
std::string_view system_tray::virtualhid_license_state_label (lvh::LicenseState state)
 Return the user-visible label for a Virtual HID Broker license state.

Variables

constexpr auto system_tray::LIBVIRTUALHID_RELEASES_URL = "https://github.com/LizardByte/libvirtualhid/releases/latest"sv
 Latest Virtual HID Broker release.

Detailed Description

Definitions for the system tray icon and notification system.