Skip to main content

WindowStateStore

Struct WindowStateStore 

Source
pub struct WindowStateStore { /* private fields */ }
Expand description

Per-app store with debounced saves.

Implementations§

Source§

impl WindowStateStore

Source

pub fn new(dir: PathBuf) -> Self

Source

pub fn dir(&self) -> &Path

Source

pub fn saved(&self, label: &str) -> Option<WindowState>

The state saved for label, if any. Reads the file; applies nothing to any window.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn schedule_save<R: Runtime>( self: &Arc<Self>, app: AppHandle<R>, label: String, )

Source

pub fn save_now<R: Runtime>( &self, app: &AppHandle<R>, label: &str, ) -> Result<(), String>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.