pub struct WebWindowState {
pub inner_size: Extent<u32, 2>,
pub outer_size: Extent<u32, 2>,
pub screen_offset: Distance<i32, 2>,
pub screen_size: Extent<u32, 2>,
pub screen_usable_size: Extent<u32, 2>,
pub dpr: f32,
pub bpp: u8,
/* private fields */
}web only.Expand description
Fields§
§inner_size: Extent<u32, 2>(innerWidth) (innerHeight) The extent in pixels of the content of the browser window including any rendered scrollbars.
outer_size: Extent<u32, 2>(outerWidth) (outerHeight) The extent in pixels of the outside of the browser window.
screen_offset: Distance<i32, 2>(screenLeft) (screenTop) The window’s offset in pixels from the screen’s top-left origin.
screen_size: Extent<u32, 2>§screen_usable_size: Extent<u32, 2>(availWidth) (availHeight) The extent of the screen in pixels, minus user interface features displayed.
dpr: f32(devicePixelRatio) The device pixel ratio of the resolution in physical pixels to the resolution in CSS pixels.
The value changes with the zoom on desktops yet remains static on mobile devices.
bpp: u8(colorDepth) The screen color depth, in bits per single pixel. It could be 8, 16, 24, 32 or 64.
Implementations§
Source§impl WebWindowState
impl WebWindowState
Sourcepub fn new() -> WebWindowState
Available on crate feature unsafe_ffi only.
pub fn new() -> WebWindowState
unsafe_ffi only.Returns a new up-to-date WebWindowState.
§Safety
- JavaScript must write all non-padding fields at correct offsets.
Sourcepub fn update(&mut self)
Available on crate feature unsafe_ffi only.
pub fn update(&mut self)
unsafe_ffi only.Overwrites this WebWindowState with the latest live metrics.
Sourcepub const fn is_valid(&self) -> bool
pub const fn is_valid(&self) -> bool
Validates the internal consistency of window metrics.
Returns true if all these conditions hold:
- No dimensions are zero (invalid window state)
- Inner size ≤ outer size (logical constraint)
- Outer size ≤ screen size (unless multi-monitor)
- Device pixel ratio is sane (0.2 <= dpr <= 10.0)
- Screen color depth is plausible (8 <= depth <= 64)
Sourcepub const fn chrome_size(&self) -> Extent<u32, 2>
pub const fn chrome_size(&self) -> Extent<u32, 2>
Returns the thickness of the window chrome (frame, scrollbars, etc.) in logical pixels.
This is the difference between the outer and inner window sizes.
Sourcepub const fn is_maximized(&self) -> bool
pub const fn is_maximized(&self) -> bool
Checks if the window is approximately maximized (fills the available screen space).
Tolerance: The window must be within 1 pixel of the screen’s usable size.
Sourcepub const fn is_portrait(&self) -> bool
pub const fn is_portrait(&self) -> bool
Checks if the window is in a portrait orientation (height > width).
Sourcepub const fn physical_size(&self) -> Extent<u32, 2>
pub const fn physical_size(&self) -> Extent<u32, 2>
Returns the physical size of the window in hardware pixels, truncating fractional values.
Computed as (inner_size * device_pixel_ratio).
For rounded values, use physical_size_rounded().
Sourcepub const fn physical_size_rounded(&self) -> Extent<u32, 2>
pub const fn physical_size_rounded(&self) -> Extent<u32, 2>
Returns the physical size of the window in hardware pixels, rounded to the nearest integer.
Computed as (inner_size * device_pixel_ratio).round().
It’s more accurate and expensive than physical_size().
Sourcepub const fn screen_margins(&self) -> [i32; 4]
pub const fn screen_margins(&self) -> [i32; 4]
Returns the window’s distance to each screen edge in logical pixels.
Order: [left, top, right, bottom]. Negative values mean the window is outside the screen.
Trait Implementations§
Source§impl Clone for WebWindowState
impl Clone for WebWindowState
Source§fn clone(&self) -> WebWindowState
fn clone(&self) -> WebWindowState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WebWindowState
Source§impl Debug for WebWindowState
impl Debug for WebWindowState
Source§impl Default for WebWindowState
impl Default for WebWindowState
Source§fn default() -> WebWindowState
fn default() -> WebWindowState
Source§impl PartialEq for WebWindowState
impl PartialEq for WebWindowState
Source§fn eq(&self, other: &WebWindowState) -> bool
fn eq(&self, other: &WebWindowState) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WebWindowState
Auto Trait Implementations§
impl Freeze for WebWindowState
impl RefUnwindSafe for WebWindowState
impl Send for WebWindowState
impl Sync for WebWindowState
impl Unpin for WebWindowState
impl UnsafeUnpin for WebWindowState
impl UnwindSafe for WebWindowState
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.