Expand description
Windowed geometry persistence ([window] remember_state).
Per-app window-state persistence.
Opt-in via [window] remember_state = true in lumen.toml.
Stores (position, size, maximized) at
<state_dir>/<app-id>/window-state.toml between runs (state_dir
follows the XDG / macOS / Windows conventions:
$XDG_STATE_HOME -> ~/.local/state on Linux,
~/Library/Application Support on macOS,
%LOCALAPPDATA% on Windows).
Save happens on LoopExiting so a normal window close persists,
and a SIGTERM / crash doesn’t (acceptable - apps usually want a
clean state if they crashed). Save also runs whenever Resized or
a future Moved event fires so kill-9 still keeps the most-recent
committed state.
Structs§
- Window
State - On-disk shape. Logical pixels for
sizeso HiDPI machines don’t see the app come back at half-size;positionis in physical pixels (winit’souter_positionunits).
Functions§
- load
- Load the persisted state for
app_id, returning a fresh default when the file doesn’t exist or fails to parse (corrupted state shouldn’t brick the app - just discard). - save
- Save
stateforapp_id. Best-effort: creates parent directories on the fly; logs to stderr on failure and returns. - state_
path - Resolve the path Lumen uses to persist a given app’s window state.
Returns
Nonewhen no per-user state dir is available (CI containers, sandboxed runs without$HOME); callers should treat that as “remember_state silently no-ops”.