Upstream: crates/rune/README.md § Multiple windows and overlays at 65f8eb43f710, MIT © Anomaly. Bundled by build-rune-apps; links point at this snapshot or at GitHub at that rev.

Multiple windows and overlays

run_windows(|displays| Vec<WindowSpec<S>>) creates independent retained trees on one winit event loop. Each spec has a stable key, an AppSpec, optional supplied state, and WindowOptions. Share Live handles/services between window states. Windows share one GPU device, with independent renderers and text atlases. WindowOptions::overlay(display) selects transparent, borderless, topmost, click-through presentation at that display's physical origin and size. Options also support initially hidden windows and per-window minimum sizes.

On macOS, WindowOptions { transparent: true, borderless: true, .. }.macos(MacWindowOptions::default().corner_radius(16.0)) rounds a window or nonactivating panel with a continuous curve (.corner_curve_circular() for a circular arc). The window's layer clips everything in it, so the root view needn't clip to the radius; a border inside the edge is still the app's. The system shadow follows the rounded shape: any transparent window with hasShadow asks AppKit to re-sample its shadow once its first frame after each show, resize or scale change (or a launcher's prewarm) reaches the screen. Opaque or bordered windows ignore the radius. To round a preset without losing what it set, amend its native options: WindowOptions::launcher_panel().macos(|native| native.corner_radius(16.0)).

WindowSpec::on_created receives a weak WindowHandle: toggle click-through, visibility and topmost status, close a window, borrow its raw-window-handle, or read its macOS window_number() (CGWindowID) for ScreenCaptureKit exclusion. By default closing a window releases its runtime; the last window closes the app. Input, focus, clocks, redraws and visibility-gated live wakes are window-local.

WindowSpec::from_app(key, app) preserves AppHandle, windowless, keep_running, close callbacks and optional GPU release for that window. Retained hosts can reopen through their AppHandle or WindowHandle. Tx::quit / AppHandle::quit exit the whole event loop. Both entry points use the same lifetime host and render path.

Windows can have different state types. App::window adds an ordinary titled window with its own state to a running app, beside its main window and overlays:

let mut app = rune::App::new(review_spec).accessory();
let capsule = app.overlay(capsule_spec, Capsule::default());
let hidden = rune::WindowOptions { visible: false, ..Default::default() };
let (settings, settings_window) = app.window(rune::WindowSpec::new("settings", settings_spec).options(hidden));
settings.update(|ui: &mut SettingsUi, _| ui.load());
// Later, from a menu item or another thread:
settings_window.open();
app.run();

The window takes keys and focus like any other; overlays still never activate. Closing it hides it and runs its on_close, and reopening shows the same state. It never keeps the app running by itself: the app ends with its main window, and Tx::quit from either window quits the process. Factories mix state types with AnyWindowSpec: run_windows(|_| vec![review.boxed(), settings.boxed()]).

Headless tools accept --window KEY and --list-windows, including windows added with App::window, and render the selected window with its own state. They use one virtual 1920×1080 display, create no native windows, and export overlays as straight-alpha PNGs. See examples/overlay for a normal control window, one overlay per monitor, a shared remote cursor, a stroke and hit-test toggling.

Monitor enumeration is a startup snapshot. Winit platform/window-manager support still governs transparency, placement and topmost behavior. Non-activating macOS NSPanels, all-Spaces/fullscreen-space policy and status items need Rune's own Mac shell; they are not implemented here. Unsupported transparency falls back to opaque rendering; unsupported click-through prints the platform error. Metal surfaces retain premultiplied colour for Core Animation.