Module tray_menu

Module tray_menu 

Source
Expand description

System tray / menu bar icon: playback controls, dynamic title + tooltip, popup menu, and (non-Linux) a WebView popover styled like macOS Now Playing (no artwork).

StructsΒ§

TrayNowPlayingPayload
TrayPopoverEmit
Serialized to the tray-popover WebView for frosted Now Playing UI.
TrayState
Per-tray state: icon + cached i18n for rebuilding the popup without hitting SQLite each tick.
TrayStateInner

ConstantsΒ§

TRAY_MENU_NOW_PLAYING_MAX πŸ”’
Max characters for the first row of the tray dropdown (macOS truncates visually; keep readable).
TRAY_POLL_MS πŸ”’
Host-side poll interval β€” 500 ms matches the popover UI’s expected cadence and is cheap since the audio-engine stdin/stdout JSON request is just a few bytes.
TRAY_POPOVER_H πŸ”’
Default height until JS measures #shell (tray_popover_resize); generous so first paint is not clipped (multi-line title + meta + directory path + progress + volume + speed + transport + padding).
TRAY_POPOVER_W πŸ”’

StaticsΒ§

TRAY_POLL_ACTIVE πŸ”’

FunctionsΒ§

build_tray_popup_menu πŸ”’
create_tray
emit_tray_popover_state πŸ”’
Set AUDIO_HAXOR_TRAY_DEBUG=1 in the environment to print every successful tray-popover-state / tray-popover-ui-theme emit to stderr (state includes the ~500 ms host poll). Emit failures always log.
emit_tray_popover_ui_theme
Light/dark from prefs (prefs_set key theme). Same debug env / failure logging as emit_tray_popover_state.
fmt_tray_time πŸ”’
normalized_popover_reveal_path πŸ”’
popover_xy_below_tray πŸ”’
scale_factor maps logical popover width to physical pixels when rect uses physical coordinates (common on macOS tray events).
refresh_tray_popup_menu
Rebuild tray popup labels from app_i18n (after UI locale change). Preserves last now-playing line.
show_main_window
Bring the main window forward (tray popover context menu β€” same intent as the native tray β€œShow” item).
start_tray_host_poll
Background thread that polls audio-engine playback_status and pushes fresh elapsed / total / paused state to the tray icon and the tray-popover WebView, regardless of JS timer throttling. The JS side (update_tray_now_playing in audio.js) still owns the title and subtitle β€” those come from DOM state that Rust cannot see β€” but this thread keeps the elapsed / total / playing fields live when the main window is unfocused (on macOS the rAF loop and setInterval both pause behind isUiIdleHeavyCpu, leaving the tray frozen).
t πŸ”’
toggle_tray_popover πŸ”’
tray_emit_ui_theme πŸ”’
tray_menu_bar_icon πŸ”’
Prefer the bundle window icon; otherwise embed 32x32.png so dev/release always have pixels.
tray_playback_speed_merge πŸ”’
tray_popover_action
tray_popover_get_state
tray_popover_get_ui_theme
tray_popover_hide
Hide the tray popover. Invoked from the main window (Escape keybind in ipc.js) so the user can dismiss the popover from any focused window β€” tray-popover.js’s own document.keydown Escape listener only fires when the popover webview itself has keyboard focus, which doesn’t happen if the popover was shown with focus: false and the user never clicked into it.
tray_popover_resize
Fit the tray-popover WebView to content (title lines, meta, fonts). Called from tray-popover.js. Width/height are CSS / logical pixels (same units as getBoundingClientRect); PhysicalSize would undersize on HiDPI and clip the HUD.
tray_popover_ui_theme_from_prefs πŸ”’
Prefs key theme β†’ popover data-theme (light vs dark HUD).
tray_volume_pct_merge πŸ”’
truncate_tray_menu_line πŸ”’
truncate_tray_title πŸ”’
update_tray_now_playing
Tauri v2 IPC: call invoke('update_tray_now_playing', { payload: … }) β€” the outer key must be payload (matches this parameter name); a flat object fails deserialization.