Sunshine master
Self-hosted game stream host for Moonlight.
system_tray Namespace Reference

Handles the system tray icon and notification system. More...

Functions

void clear_tray_notification ()
 Clear notification fields before replacing the tray state.
 
int end_tray ()
 Exit the system tray.
 
const char * GetResourcePath (const char *relativePath)
 Get resource path.
 
int init_tray ()
 Initializes the system tray without starting a loop.
 
int init_tray_threaded ()
 Initializes and runs the system tray in a separate thread.
 
int 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, 11 > initial_virtualhid_license_menu ()
 Create the initial Virtual HID Driver license submenu.
 
void prepare_tray_virtualhid_license ()
 Query the Virtual HID Driver license and prepare the startup tray state.
 
int process_tray_events ()
 Processes a single tray event iteration.
 
void rebuild_virtualhid_license_menu (const lvh::LicenseStatus &license)
 Rebuild the Virtual HID Driver submenu for the latest license state.
 
void resolve_tray_icon_paths ()
 Resolve tray icons against the current executable or application bundle.
 
template<typename Callback = std::nullptr_t>
void 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 Driver submenu item.
 
void tray_donate_github_cb (struct tray_menu *item)
 Callback for opening GitHub Sponsors from the system tray.
 
void tray_donate_patreon_cb (struct tray_menu *item)
 Callback for opening Patreon from the system tray.
 
void tray_donate_paypal_cb (struct tray_menu *item)
 Callback for opening PayPal donation from the system tray.
 
void tray_open_ui_cb (struct tray_menu *item)
 Callback for opening the UI from the system tray.
 
void tray_quit_cb (struct tray_menu *item)
 Callback for exiting Sunshine from the system tray.
 
void tray_reset_display_device_config_cb (struct tray_menu *item)
 Callback for resetting display device configuration.
 
void tray_restart_cb (struct tray_menu *item)
 Callback for restarting Sunshine from the system tray.
 
void tray_virtualhid_download_cb (struct tray_menu *item)
 Callback for opening the latest Virtual HID Driver release.
 
void tray_virtualhid_license_cb (struct tray_menu *item)
 Callback for opening Virtual HID Driver license settings in the Web UI.
 
void 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 update_tray_playing (std::string app_name)
 Sets the tray icon in playing mode and spawns the appropriate notification.
 
void update_tray_require_pin ()
 Spawns a notification for PIN Pairing. Clicking it opens the PIN Web UI Page.
 
void update_tray_stopped (std::string app_name)
 Sets the tray icon in stopped mode (app and stream stopped) and spawns the appropriate notification.
 
void update_tray_virtualhid_license (const lvh::LicenseStatus &license, bool notify_if_unlicensed)
 Update the Virtual HID Driver license submenu and optional notification.
 
std::string_view virtualhid_license_state_detail (lvh::LicenseState state)
 Return explanatory tray text for a non-active license state.
 
std::string_view virtualhid_license_state_label (lvh::LicenseState state)
 Return the user-visible label for a Virtual HID Driver license state.
 

Variables

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

Detailed Description

Handles the system tray icon and notification system.

Function Documentation

◆ end_tray()

int system_tray::end_tray ( )

Exit the system tray.

Returns
0 after exiting the system tray.

◆ GetResourcePath()

const char * system_tray::GetResourcePath ( const char * relativePath)

Get resource path.

Parameters
relativePathRelative path.
Returns
Absolute path to the resource file for the current platform bundle layout.

◆ init_tray()

int system_tray::init_tray ( )

Initializes the system tray without starting a loop.

Returns
0 if initialization was successful, non-zero otherwise.

◆ init_tray_threaded()

int system_tray::init_tray_threaded ( )

Initializes and runs the system tray in a separate thread.

Returns
0 if initialization was successful, non-zero otherwise.

◆ init_tray_with_stop_token()

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.

Parameters
stop_tokenStop token supplied by the managed tray worker, or an empty token for direct initialization.
Returns
Zero when initialization succeeds; otherwise, a non-zero error code.

◆ initial_virtualhid_license_menu()

std::array< struct tray_menu, 11 > system_tray::initial_virtualhid_license_menu ( )

Create the initial Virtual HID Driver license submenu.

Returns
Menu storage with a checking state, benefits, license settings, and driver download.

◆ process_tray_events()

int system_tray::process_tray_events ( )

Processes a single tray event iteration.

Returns
0 if processing was successful, non-zero otherwise.

◆ rebuild_virtualhid_license_menu()

void system_tray::rebuild_virtualhid_license_menu ( const lvh::LicenseStatus & license)

Rebuild the Virtual HID Driver submenu for the latest license state.

Parameters
licenseLatest machine license details.

◆ set_virtualhid_license_menu_item()

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 Driver submenu item.

Template Parameters
CallbackCallback type accepted by the tray library.
Parameters
indexSubmenu index to populate.
textUser-visible menu text.
disabledWhether the item is informational rather than actionable.
callbackCallback invoked for actionable items.

◆ tray_donate_github_cb()

void system_tray::tray_donate_github_cb ( struct tray_menu * item)

Callback for opening GitHub Sponsors from the system tray.

Parameters
itemThe tray menu item.

◆ tray_donate_patreon_cb()

void system_tray::tray_donate_patreon_cb ( struct tray_menu * item)

Callback for opening Patreon from the system tray.

Parameters
itemThe tray menu item.

◆ tray_donate_paypal_cb()

void system_tray::tray_donate_paypal_cb ( struct tray_menu * item)

Callback for opening PayPal donation from the system tray.

Parameters
itemThe tray menu item.

◆ tray_open_ui_cb()

void system_tray::tray_open_ui_cb ( struct tray_menu * item)

Callback for opening the UI from the system tray.

Parameters
itemThe tray menu item.

◆ tray_quit_cb()

void system_tray::tray_quit_cb ( struct tray_menu * item)

Callback for exiting Sunshine from the system tray.

Parameters
itemThe tray menu item.

◆ tray_reset_display_device_config_cb()

void system_tray::tray_reset_display_device_config_cb ( struct tray_menu * item)

Callback for resetting display device configuration.

Parameters
itemThe tray menu item.

◆ tray_restart_cb()

void system_tray::tray_restart_cb ( struct tray_menu * item)

Callback for restarting Sunshine from the system tray.

Parameters
itemThe tray menu item.

◆ tray_virtualhid_download_cb()

void system_tray::tray_virtualhid_download_cb ( struct tray_menu * item)

Callback for opening the latest Virtual HID Driver release.

Parameters
itemThe tray menu item.

◆ tray_virtualhid_license_cb()

void system_tray::tray_virtualhid_license_cb ( struct tray_menu * item)

Callback for opening Virtual HID Driver license settings in the Web UI.

Parameters
itemThe tray menu item.

◆ update_tray_pausing()

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.

Parameters
app_nameThe paused application name

◆ update_tray_playing()

void system_tray::update_tray_playing ( std::string app_name)

Sets the tray icon in playing mode and spawns the appropriate notification.

Parameters
app_nameThe started application name

◆ update_tray_stopped()

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.

Parameters
app_nameThe started application name

◆ update_tray_virtualhid_license()

void system_tray::update_tray_virtualhid_license ( const lvh::LicenseStatus & license,
bool notify_if_unlicensed )

Update the Virtual HID Driver license submenu and optional notification.

Parameters
licenseLatest machine license details.
notify_if_unlicensedWhether to notify the user when the machine is not activated.

◆ virtualhid_license_state_detail()

std::string_view system_tray::virtualhid_license_state_detail ( lvh::LicenseState state)

Return explanatory tray text for a non-active license state.

Parameters
stateLicense state reported by libvirtualhid.
Returns
Short explanation of the state.

◆ virtualhid_license_state_label()

std::string_view system_tray::virtualhid_license_state_label ( lvh::LicenseState state)

Return the user-visible label for a Virtual HID Driver license state.

Parameters
stateLicense state reported by libvirtualhid.
Returns
Short state label suitable for a tray menu.