pub struct PhysicalRect {
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
}Expand description
An axis-aligned rectangle in device pixels.
Each use names its space. Monitor geometry is in the desktop’s, where the
origin is the desktop origin rather than a window corner and coordinates can
be negative (a monitor placed left of the primary one);
Shell::set_text_input_area is in a
window’s client area.
Fields§
§x: i32Left edge, in device pixels of the space the use names.
y: i32Top edge, in device pixels of the space the use names.
width: u32Width in device pixels.
height: u32Height in device pixels.
Implementations§
Source§impl PhysicalRect
impl PhysicalRect
Sourcepub const fn new(x: i32, y: i32, width: u32, height: u32) -> Self
pub const fn new(x: i32, y: i32, width: u32, height: u32) -> Self
A rectangle at (x, y) of width × height device pixels.
Sourcepub const fn size(self) -> PhysicalSize
pub const fn size(self) -> PhysicalSize
The rectangle’s size.
Sourcepub const fn contains(self, x: i32, y: i32) -> bool
pub const fn contains(self, x: i32, y: i32) -> bool
Whether a desktop-space point lies inside.
Half-open: the left and top edges belong to this rectangle, the
right and bottom ones do not. Monitors tile edge to edge — the standard
side-by-side layout is (0,0,1920,1080) next to (1920,0,1920,1080) —
so an inclusive far edge would put the first column of the second
monitor inside both, and the monitor lookup in the X11 backend returns
the first match. Half-open makes the tiling a partition.
The subtraction is widened to i64 before it happens, not after: a
rectangle at a negative origin and a point near i32::MAX overflow an
i32 difference, which panics in debug and wraps to “inside” in
release.