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.
Sourcepub fn rounded(self, radius: u32) -> Vec<Self>
pub fn rounded(self, radius: u32) -> Vec<Self>
This rectangle with its corners rounded to radius device pixels, as
the union of rectangles
Shell::set_input_region takes.
An outer bound: every pixel a corner’s quarter circle covers at all is inside, so a panel drawn with antialiased rounded corners keeps its whole edge — which matters on Win32, where the region also clips what the window draws. Neighbouring rows with the same inset are merged, so the count grows with the radius rather than the height, and the rectangles never overlap. The radius is clamped to half the shorter side; an empty rectangle gives none.