pub struct Window { /* private fields */ }Expand description
A cross-platform window.
The window is reference-counted internally and can be cloned cheaply.
Implementations§
Source§impl Window
impl Window
Sourcepub fn new(event_loop: &ActiveEventLoop, config: &WindowConfig) -> Result<Self>
pub fn new(event_loop: &ActiveEventLoop, config: &WindowConfig) -> Result<Self>
Create a new window with the given configuration.
§Errors
Returns an error if the window could not be created.
Sourcepub fn inner_size(&self) -> PhysicalSize<u32>
pub fn inner_size(&self) -> PhysicalSize<u32>
Get the current inner size of the window in physical pixels.
Sourcepub fn scale_factor(&self) -> f64
pub fn scale_factor(&self) -> f64
Get the window’s scale factor (DPI scaling).
Sourcepub fn request_redraw(&self)
pub fn request_redraw(&self)
Request a redraw of the window.
Sourcepub fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
pub fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>
Get the raw window handle for GPU surface creation.
§Errors
Returns an error if the window handle cannot be obtained.
Sourcepub fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
pub fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
Get the raw display handle for GPU surface creation.
§Errors
Returns an error if the display handle cannot be obtained.
Sourcepub fn winit_window(&self) -> &Window
pub fn winit_window(&self) -> &Window
Get a reference to the underlying winit window.
This is useful for advanced use cases that need direct winit access.
Trait Implementations§
impl Send for Window
impl Sync for Window
Auto Trait Implementations§
impl !RefUnwindSafe for Window
impl !UnwindSafe for Window
impl Freeze for Window
impl Unpin for Window
impl UnsafeUnpin for Window
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.