pub struct SizeConstraints {
pub min: Option<LogicalSize>,
pub max: Option<LogicalSize>,
pub aspect: Option<AspectRatio>,
}Expand description
Limits the window system should enforce on an interactive resize.
All three are hints in the strict sense: a tiling window manager honours
none of them, and Wayland has no aspect hint at all. Consumers must stay
correct when they are ignored — which for aspect means letterboxing
in-renderer with AspectRatio::fit, the universal fallback.
Fields§
§min: Option<LogicalSize>Smallest client area the user may resize to.
max: Option<LogicalSize>Largest client area the user may resize to.
aspect: Option<AspectRatio>Ratio the client area should keep during a resize.
Honoured natively only where
ShellCaps::ASPECT_HINT_HONORED
is set. Where it is not, a backend picks the nearest aspect-correct size
it is allowed to pick and the renderer letterboxes the remainder.
Implementations§
Source§impl SizeConstraints
impl SizeConstraints
Sourcepub const fn min(size: LogicalSize) -> Self
pub const fn min(size: LogicalSize) -> Self
Constraints with a minimum size and nothing else.
Sourcepub const fn with_aspect(self, aspect: AspectRatio) -> Self
pub const fn with_aspect(self, aspect: AspectRatio) -> Self
These constraints with an aspect lock added.
Sourcepub fn apply(&self, size: PhysicalSize, scale_factor: f64) -> PhysicalSize
pub fn apply(&self, size: PhysicalSize, scale_factor: f64) -> PhysicalSize
Applies the constraints to a physical size, as a backend that cannot delegate to the window system would.
Clamping happens before the aspect fit, so the result never exceeds
max. It can fall below min when an aspect lock demands it: a size
that violates the aspect ratio is visibly wrong, while one a few pixels
under the minimum is not, and something has to give when the two
disagree.
HeadlessShell applies this, which is what
makes constraint behaviour testable without a window manager.