pub struct PerWindowState {
pub label: String,
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
pub placement: WindowPlacement,
}Expand description
Persisted geometry for one labeled window.
placement captures the full WindowPlacement enum (Floating /
Maximized / Fullscreen / Minimized). On restore, Minimized is
downgraded to Floating so the app doesn’t appear to fail to
start; every other variant is honored if the OS supports it
(Wayland will ignore position regardless — see sanitize’s
docs).
Fields§
§label: String§x: i32§y: i32§width: u32§height: u32§placement: WindowPlacementImplementations§
Source§impl PerWindowState
impl PerWindowState
Sourcepub fn sanitize(
&self,
min_size: (u32, u32),
work_area: (u32, u32),
) -> PerWindowState
pub fn sanitize( &self, min_size: (u32, u32), work_area: (u32, u32), ) -> PerWindowState
Validate this state against a (width, height) work area
(typically the size of the largest available monitor’s usable
region) and return a sanitized copy:
width/heightare clamped to[min, work_area]. If the minimum is larger than the work area the work area wins — this should not happen with sensible mins (e.g. 320x240).- The position is checked: if the top-left point lies
outside
[0, work_area_w) x [0, work_area_h)and the window would not have at least 50 logical-pixel intersection with the work area, the position is recentered on the monitor so the window comes back on screen instead of spawning at coordinates from a missing monitor. maximizedandlabelare preserved.
Use this on app startup with (work_area_w, work_area_h)
pulled from the OS (e.g. winit’s MonitorHandle::size() minus
known taskbars). Without an OS hint, pass conservative
fallbacks like (1920, 1080) — the result still improves on
re-using stale coordinates from a monitor that’s no longer
connected.
Trait Implementations§
Source§impl Clone for PerWindowState
impl Clone for PerWindowState
Source§fn clone(&self) -> PerWindowState
fn clone(&self) -> PerWindowState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PerWindowState
impl Debug for PerWindowState
Source§impl<'de> Deserialize<'de> for PerWindowState
impl<'de> Deserialize<'de> for PerWindowState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PerWindowState
impl PartialEq for PerWindowState
Source§fn eq(&self, other: &PerWindowState) -> bool
fn eq(&self, other: &PerWindowState) -> bool
self and other values to be equal, and is used by ==.