// Optional tray-icon indicator for the long-running sherpa_server process. // Windows-only; on other platforms the StartTrayIcon / StopTrayIcon calls // are no-ops via the #ifdef _WIN32 stub at the bottom of the .cpp. // // The icon tells the user a background TTS helper is running and offers a // right-click "Exit" to shut it down. The process is normally reaped by the // parent (the Numen NVSE plugin spawns sherpa_server.exe into a kill-on-close // Job Object); Exit is the manual path for when the helper is left running // standalone. The stdin request loop can't be unblocked from the tray thread, // so sherpa_server passes no onExit hook and Exit calls ExitProcess. // // Mirrors third-party/piper/src/cpp/tray_icon_win32.{hpp,cpp}; duplicated // rather than shared because the two helpers ship out of independent CMake // trees (piper is a submodule, sherpa_server is in this repo). Keep the // two copies in sync when touching either. #pragma once #include #include namespace sherpa { // Add a tray icon with the given tooltip text. The optional onExit hook is // invoked on the tray thread when the user picks "Exit"; pass it to shut the // host down gracefully. When empty, "Exit" terminates the process via // ExitProcess. Idempotent; subsequent calls are ignored while an icon is // already active. The icon and its hidden message-only window live on a // dedicated thread so the request loop on the main thread is unaffected. void StartTrayIcon(const std::string& tooltip, std::function onExit = {}); // Remove the tray icon and wait briefly for the message-pump thread to // exit. Safe to call from a normal exit path; on TerminateProcess the // OS reaps the icon anyway. void StopTrayIcon(); } // namespace sherpa