Skip to main content

Module app_state

Module app_state 

Source
Expand description

OS-window state persistence helpers.

Apps using agg-gui typically want to restore the OS window’s size, fullscreen, and maximized state across launches. This module packages the small serializable record and shared cells that the platform harness writes into / reads from. The app-specific bits (which demo windows were open, positions of floating Window widgets, etc.) are NOT here — those belong to the app’s own state struct; this handles only the OS-window level.

§Usage sketch

// Somewhere in app setup:
let os_window = agg_gui::OsWindowHandle::new();

// In winit's Resized handler:
os_window.size.set((new_size.width, new_size.height));
os_window.fullscreen.set(window.fullscreen().is_some());
os_window.maximized.set(window.is_maximized());

// On close / every idle tick, serialize `OsWindowState::from_handle(&os_window)`
// and write it wherever app state lives.  On startup, parse it back and
// apply via `WindowAttributes::with_inner_size` / `with_maximized` /
// `with_fullscreen`, then after the window is live call
// `window.set_fullscreen(...)` / `set_maximized(true)` as a
// belt-and-suspenders (some platforms ignore the initial attribute).

See demo-native/src/main.rs for a complete wiring.

Structs§

OsWindowHandle
Live shared cells the platform harness mutates during the event loop.
OsWindowState
Snapshot of the OS window state — serialisable.