pub struct WindowStateStore { /* private fields */ }Expand description
Per-app store with debounced saves.
Implementations§
Source§impl WindowStateStore
impl WindowStateStore
pub fn new(dir: PathBuf) -> Self
pub fn dir(&self) -> &Path
Sourcepub fn saved(&self, label: &str) -> Option<WindowState>
pub fn saved(&self, label: &str) -> Option<WindowState>
The state saved for label, if any. Reads the file; applies nothing to any window.
Sourcepub fn import_legacy(
&self,
source_id: &str,
legacy_file: &Path,
label_map: &[(&str, &str)],
) -> Result<LegacyImport, String>
pub fn import_legacy( &self, source_id: &str, legacy_file: &Path, label_map: &[(&str, &str)], ) -> Result<LegacyImport, String>
Import a legacy per-app geometry store once (M1-G5; CodeRight window_state/mod.rs:92,110-118
shape: a flat label -> state JSON object, version 0 meaning physical pixels).
Each legacy entry runs through the same v0 -> v1 migration the store applies on load, then is
added under its owner label (label_map is (legacy, owner) pairs; an empty map keeps every
label). An owner entry that already exists is never overwritten. Idempotent: a marker file
window-state.imported-<source_id> is written after the first attempt that found the legacy
file (a missing file is not marked, so a later-appearing file still imports), and later
calls return LegacyImport::AlreadyImported. The legacy file is left in place. A legacy
file that does not parse is reported as an error and not marked.
Sourcepub fn save_state(&self, label: &str, state: WindowState) -> Result<(), String>
pub fn save_state(&self, label: &str, state: WindowState) -> Result<(), String>
Record state for label without touching a window (a host that tracks its own geometry,
or a test).
Sourcepub fn restore<R: Runtime>(
&self,
app: &AppHandle<R>,
label: &str,
) -> Result<bool, String>
pub fn restore<R: Runtime>( &self, app: &AppHandle<R>, label: &str, ) -> Result<bool, String>
Apply saved geometry to label (hidden or not). Returns whether a saved state existed.
Positions only; equal to WindowStateStore::restore_with with the default options.
Sourcepub fn restore_with<R: Runtime>(
&self,
app: &AppHandle<R>,
label: &str,
options: &RestoreOptions,
) -> Result<bool, String>
pub fn restore_with<R: Runtime>( &self, app: &AppHandle<R>, label: &str, options: &RestoreOptions, ) -> Result<bool, String>
WindowStateStore::restore that can also bring the window up: options may unminimise,
show and focus it, and re-minimise a window saved minimised. The visibility options apply
whenever the window exists, saved geometry or not (a first run still shows). Returns whether
saved geometry was applied. Nothing calls this for you outside the full Shell plugin.