Platform window controls and integrations
Spotifast connects its music actions and window behavior to the desktop system around it. The main app stays in charge of playback and navigation while platform surfaces such as macOS menus, the MacBook notch, Windows taskbar previews, Hyprland, and the single-instance channel provide alternate ways to reach the same actions.
This page extends Desktop UI and interaction with platform-facing behavior. For shared controls and navigation, see UI navigation and shared components.
Window behavior
The window layer keeps the main and mini-player windows usable across desktop systems. It restores only usable saved sizes, moves rendering controls to the platform where the window system allows them, and reports clear help when graphics support prevents a window from opening. The app treats Wayland, X11, Windows, and macOS as different window environments rather than assuming that one window rule works everywhere. src/window.rs• L1-18
Window placement and taskbar presence
Window placement protects the user from stale session data and platform limits. A saved size below the current minimum is ignored. A request to keep a window above others is offered as a desktop rule on Wayland because the app cannot set that level there. The mini player can stay out of the taskbar on Windows and X11, while macOS uses the Dock and Wayland has no matching app-level control. src/window.rs• L65-108
The mini-player and skinned windows use the same window policy as their product role. A mini-player may be hidden from the taskbar when the platform supports it. A Winamp skin uses borderless, transparent windows and asks the desktop compositor to avoid adding a frame around pixels that the skin already draws. src/…/wmp.rs• L68-95, src/app.rs• L1562-1579
References: src/window.rs• L65-108 src/…/wmp.rs• L68-95 src/app.rs• L1562-1579
Window lifecycle
The application state outlives a visible window. Closing to the tray removes the window while playback, the tray, and desktop control channels continue. A later request can create a new window around the same state, so platform controls must attach to each new window and must not own the application state. src/entrypoint.rs• L403-425, src/app.rs• L1562-1584
References: src/entrypoint.rs• L403-425 src/app.rs• L1562-1584
Link integration
Link integration turns links from the desktop, command line, or a second launch into one internal Spotify URI. The parser accepts Spotify protocol and web forms for supported resource pages and search links, rejects unrelated links, and removes delivery-specific details before the app opens the target page. src/link.rs• L1-7
The link flow keeps external delivery separate from page navigation. macOS receives URL Apple Events and places valid links on the running instance's command queue. A launch with a link follows the same path after instance coordination. The app then raises its window and opens the page when account state allows it. src/mac_links.rs• L1-8, src/mac_links.rs• L70-117, src/app.rs• L9985-9989
The following flow shows how an outside link reaches the same app action regardless of its source.
flowchart LR
A[Desktop URL event] --> N[Normalize Spotify link]
B[Command-line launch] --> N
C[Second launch] --> D[Single-instance channel]
D --> N
N --> Q[Running instance command queue]
Q --> W[Bring window forward]
W --> P[Open Spotify page]
macOS controls
The macOS integration exposes the app through the native menu bar and Dock menu. Menu items cover playback, volume, navigation, library views, settings, updates, shortcuts, editing, and window actions. The native handler sends commands back to the normal app action queue, so menu actions follow the same state and playback rules as in-app controls. src/mac_menu.rs• L1-31, src/entrypoint.rs• L1345-1402
Menu bar and Dock menu
The menu bar is built when a window is created and remains connected to a handler for the process lifetime. The Dock menu is rebuilt when opened so its first item says Play or Pause for the current state. Dock playback commands use a separate queue because the app can keep running in the tray without a visible window. src/mac_menu.rs• L73-85, src/mac_menu.rs• L293-375
Editing commands are routed through the app's text-input system. This preserves cut, copy, paste, and select-all behavior in egui fields instead of relying on a responder chain that the window view does not implement. src/mac_menu.rs• L251-274, src/entrypoint.rs• L1374-1399
References: src/mac_menu.rs• L293-375 src/mac_menu.rs• L467-503 src/mac_menu.rs• L715-722 src/entrypoint.rs• L1345-1402
Touch Bar safety
The Touch Bar guard protects window close from a known AppKit observer cleanup fault. It filters only the known Touch Bar exception and lets unrelated observer failures remain visible, so the guard limits a platform crash without hiding new lifecycle bugs. src/mac_touchbar_crash_guard.rs• L1-22, src/mac_touchbar_crash_guard.rs• L84-132
References: src/mac_touchbar_crash_guard.rs• L1-22 src/mac_touchbar_crash_guard.rs• L84-132
MacBook notch widget
The MacBook notch widget is an optional background Now Playing surface. It appears only when the feature is enabled, music is available, the main app is not in the foreground, and the active display has a physical notch. Hover expands the notch into a playback card; leaving it collapses the card after a short delay. src/…/settings.rs• L837-844, src/notch.rs• L48-86, src/mac_notch.rs• L1480-1503
The widget mirrors current track data and sends its controls into the normal action queue. It supports play or pause, previous and next, seeking, shuffle, repeat, saving supported tracks, and returning to the main window. Track changes update the card while incremental playback changes avoid replacing the whole presentation. src/notch.rs• L3-26, src/mac_notch.rs• L1542-1652
The following flow shows when the notch surface exists and how a user action returns to the main application.
flowchart TD
S[Playback and window state] --> V{Enabled, background, track, physical notch?}
V -- No --> H[Hide widget]
V -- Yes --> C[Show collapsed notch]
C -->|Hover| E[Expand Now Playing card]
E -->|Playback or seek action| A[Queue normal app action]
A --> S
E -->|Pointer leaves| K[Collapse card]
Windows thumbbar
The Windows thumbbar adds three transport buttons below the taskbar preview of the visible window. The buttons are always Previous, Play or Pause, and Next. They are enabled only when a track exists and the current device accepts control, so the preview does not promise actions that playback cannot perform. src/thumbbar.rs• L1-14, src/thumbbar.rs• L67-127
The toolbar follows the taskbar button rather than the process alone. It is installed when Windows exposes the window in the taskbar, refreshed when playback changes, and installed again if Explorer restarts or the window is recreated. Its icons follow the Windows shell theme and display scale instead of the app theme. src/…/win.rs• L95-115, src/…/win.rs• L301-374
Thumbbar presses are converted to the same previous, toggle-play, and next actions used by other desktop controls. The shell wakes the frame loop when Windows sends a press, and the app checks the current playback state before accepting the action. src/entrypoint.rs• L1403-1412, src/thumbbar.rs• L45-55
Hyprland integration
Hyprland integration removes compositor decoration from Winamp skin windows. A skin paints its own complete surface, so an extra border, corner radius, shadow, or blur effect changes the product appearance. The integration changes only windows owned by this Spotifast process and leaves the normal main window decorated. src/hyprland.rs• L1-7, src/app.rs• L1573-1578
The integration waits for each new skin window to appear in Hyprland, then applies the border rules through the compositor socket. New requests supersede older attempts, which matters when the main window and several skin windows are created close together. If the Hyprland socket is not available, the app keeps normal window behavior without blocking startup. src/hyprland.rs• L14-33, src/hyprland.rs• L77-111
Single-instance coordination
Single-instance coordination prevents duplicate Spotify Connect devices, media players, and tray icons. The first launch holds a per-user slot. A later launch sends its request to that instance and exits instead of starting a rival app. src/single_instance.rs• L1-12, src/single_instance.rs• L198-246
The channel supports both commands and read snapshots. Commands enter the same action queue as tray and media-key input. Read requests return the latest now-playing or device snapshot without touching app state from the listener thread. Links are validated before they enter the queue, and a hidden launch can ask for a snapshot without bringing the existing window forward. src/single_instance.rs• L14-25, src/single_instance.rs• L250-287
The coordination path is shared by command-line control, external links, and the running app. This keeps all outside requests behind one validation boundary and lets the long-lived app decide how each accepted request affects playback or navigation. src/entrypoint.rs• L386-429, src/app.rs• L5688-5733
sequenceDiagram
participant L as New launch or client
participant G as Instance slot
participant R as Running app
participant A as Action queue
L->>G: Claim or send request
alt First instance
G-->>L: Own slot
R->>G: Publish snapshots
else Existing instance
G->>R: Deliver validated request
R->>A: Queue app action
R-->>L: Return ok or snapshot
L-->>L: Exit
end
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every external link source mapped to the same canonical URI before it reaches
Action::OpenLink. - Keep macOS menu, Dock, notch, Windows thumbbar, tray, and single-instance commands aligned with the shared action meanings.
- When a window can be recreated, reattach window-owned integrations and do not move long-lived playback state into them.
- If the notch track data changes, update both the visibility rules and the command-to-action path.
- If the Windows thumbbar button set changes, preserve its fixed identifiers and rebuild behavior after Explorer or window recreation.
- If Winamp window decoration rules change, keep normal main-window borders separate from skin-window rules.
- If the single-instance request or snapshot shape changes, update both clients and the running-instance handler together.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A second launch starts its own app instead of handing off | Duplicate Connect, media, and tray presence | The per-user instance slot rejects the second owner and delivers its request to the running instance. |
| A non-Spotify or malformed external link reaches navigation | The app may open an invalid or unintended target | Link parsing canonicalizes only supported Spotify resources and rejects other schemes and shapes. |
| The MacBook notch widget remains visible with no track or in the foreground | An overlay hides or intercepts the main app | Visibility requires the feature, background state, a track, and a physical notch. |
| Explorer restarts after the thumbbar is installed | The taskbar preview returns without transport buttons | A new taskbar-button notification causes the toolbar to be added again. |
| A skin window receives normal Hyprland decoration | The skin has an unwanted border, rounding, shadow, or blur | Hyprland rules apply only to this process's skin windows and can be cancelled for the main window. |
| AppKit raises an unrelated observer exception during close | A real lifecycle defect could be hidden or mishandled | The Touch Bar guard swallows only the known _NSTouchBarFinderObservation case and rethrows others. |
Key files
| File | Why to read it |
|---|---|
| src/window.rs | Cross-platform window limits, taskbar behavior, minimization, and graphics failure guidance. |
| src/link.rs | Canonical external-link contract used by launches, macOS URL events, and app navigation. |
| src/mac_menu.rs | Native macOS menu bar and Dock playback surface. |
| src/mac_links.rs | macOS URL-event delivery into the running app. |
| src/mac_notch.rs | MacBook notch surface and its state updates. |
| src/notch.rs | Notch visibility rules, commands, and platform-neutral state model. |
| src/thumbbar.rs | Windows thumbbar state and transport contract. |
| src/…/win.rs | Windows taskbar lifecycle and shell integration. |
| src/hyprland.rs | Hyprland decoration policy for skin windows. |
| src/single_instance.rs | Single-instance ownership, request validation, command delivery, and snapshots. |
| src/entrypoint.rs | Startup handoff and attachment of platform controls to each window. |
| src/app.rs | Shared action routing and state publication for platform controls. |