Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
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, 9 > initial_virtualhid_license_menu ()
 Create the initial Virtual HID Broker license submenu.
void prepare_tray_virtualhid_driver ()
 Query the Virtual HID Broker version and prepare its startup notification.
void prepare_tray_virtualhid_license ()
 Query the Virtual HID Broker 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 Broker submenu for the latest license state.
void resolve_tray_icon_paths ()
 Resolve tray icons against the current executable or application bundle.
void 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 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 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_native_menu_click_cb (struct tray *tray_icon)
 Leave macOS tray menu presentation to Qt's native status item.
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 Broker release.
void tray_virtualhid_license_cb (struct tray_menu *item)
 Callback for opening Virtual HID Broker 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_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 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 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 Broker license state.

Variables

constexpr auto LIBVIRTUALHID_RELEASES_URL = "https://github.com/LizardByte/libvirtualhid/releases/latest"sv
 Latest Virtual HID Broker 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, 9 > system_tray::initial_virtualhid_license_menu ( )

Create the initial Virtual HID Broker 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 Broker submenu for the latest license state.

Parameters
licenseLatest machine license details.

◆ run_tray_until_exit()

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.

Parameters
shutdown_eventEvent used to stop Sunshine's server threads.

◆ 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 Broker 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_native_menu_click_cb()

void system_tray::tray_native_menu_click_cb ( struct tray * tray_icon)

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.

Parameters
tray_iconTray icon that received the click.

◆ 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 Broker 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 Broker 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_driver()

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.

Existing notifications are preserved when gamepad input is disabled, the broker is absent or supported, or the Windows backend choice does not use the broker.

Parameters
installedWhether the broker is installed.
versionInstalled broker version.
version_compatibleWhether Sunshine supports the installed version.
supported_versionsUser-visible supported version range.

◆ update_tray_virtualhid_license()

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.

Parameters
licenseLatest machine license details.
notify_if_unlicensedWhether to notify the user when the broker needs a license.

◆ 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 Broker license state.

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