pub struct Window<'dpy>(/* private fields */);Expand description
The closest possible representation of a desktop window.
Such a concept might not exist on some platforms, in which case, the single window you “create” actually returns an abstraction over the “canvas” or “screen space” you’re allowed to draw to.
See Display to see how to create them.
Implementations§
Source§impl<'a, 'b: 'a, 'dpy: 'b> Window<'dpy>
impl<'a, 'b: 'a, 'dpy: 'b> Window<'dpy>
pub fn get_capabilities(&self) -> Capabilities
Sourcepub fn show(&self) -> WindowOpResult
pub fn show(&self) -> WindowOpResult
A window won’t appear until this method is called.
Sourcepub fn hide(&self) -> WindowOpResult
pub fn hide(&self) -> WindowOpResult
The obvious reciprocal of show().
Sourcepub fn set_title(&self, title: &str) -> WindowOpResult
pub fn set_title(&self, title: &str) -> WindowOpResult
Sets the window’s title.
pub fn set_icon<I: Into<Option<Icon>>>(&self, icon: I) -> WindowOpResult
Sourcepub fn set_style(&self, style: &Style) -> WindowOpResult
pub fn set_style(&self, style: &Style) -> WindowOpResult
Attempts to set the window’s borders.
Sourcepub fn recenter(&self) -> WindowOpResult
pub fn recenter(&self) -> WindowOpResult
Centers a window relatively to the space it is in, with regards to its size.
Sourcepub fn set_opacity(&self, opacity: f32) -> WindowOpResult
pub fn set_opacity(&self, opacity: f32) -> WindowOpResult
Sets the window’s opacity, provided the window was created with
the fully_opaque flag set to false.
Valid values for opacity range from 0 to 1 (both inclusive).
You’re expected to clamp the value yourself if needed.
Sourcepub unsafe fn get_internal(&'b self) -> &'a Window<'_>
pub unsafe fn get_internal(&'b self) -> &'a Window<'_>
Retrieves the window’s internal implementation details, if you need to work around missing features.
If that happens, you are welcome to report an issue!
Sourcepub unsafe fn get_internal_mut(&'dpy mut self) -> &'a mut Window<'_>
pub unsafe fn get_internal_mut(&'dpy mut self) -> &'a mut Window<'_>
Retrieves the window’s internal implementation details, if you need to work around missing features.
If that happens, you are welcome to report an issue!
Sourcepub fn create_child(
&'b mut self,
settings: &Settings,
) -> Result<Window<'a>, Error>
pub fn create_child( &'b mut self, settings: &Settings, ) -> Result<Window<'a>, Error>
Attempts to create a child window.
The definition of “child window” may vary slightly from platform to platform, but it’s almost always just another window which is closed when its parent gets closed.
Sourcepub fn query_screenspace_size(&self) -> Extent2<u32>
pub fn query_screenspace_size(&self) -> Extent2<u32>
The window’s size, in screen coordinates.
You should not rely on this being equal to its size
in raster-space coordinates.
If you’re interested in the “canvas”’s dimensions,
use the query_canvas_size() method instead.
The query() part means that the operation is possibly heavy and
the result is not implicitly cached:
it’s your responsibility to do so if this is what you want.
Sourcepub fn query_canvas_size(&self) -> Extent2<u32>
pub fn query_canvas_size(&self) -> Extent2<u32>
The window’s size, in raster-space coordinates.
On High-DPI-enabled windows, it should be bigger
than the size in screen-coordinates.
This is what you should use for pixel-perfect rendering.
The query() part means that the operation is possibly heavy and
the result is not implicitly cached:
it’s your responsibility to do so if this is what you want.
Sourcepub fn maximize(&self) -> WindowOpResult
pub fn maximize(&self) -> WindowOpResult
Attempts to maximize the window (as in, take as much space as possible).
Sourcepub fn minimize(&self) -> WindowOpResult
pub fn minimize(&self) -> WindowOpResult
Attempts to minimize the window (as in, minimize to task bar).
Sourcepub fn restore(&self) -> WindowOpResult
pub fn restore(&self) -> WindowOpResult
The reciprocal of minimize().
Sourcepub fn raise(&self) -> WindowOpResult
pub fn raise(&self) -> WindowOpResult
Attempts to set the window on top of the stack and request focus.
Sourcepub fn enter_fullscreen(&self) -> WindowOpResult
pub fn enter_fullscreen(&self) -> WindowOpResult
Attempts to go full-screen.
The Window struct doesn’t keep track of an is_fullscreen
boolean: it is yours to manage if you need one. This method
won’t perform the checks for you.
However, for convenience, it saves the window’s current size
to automatically restore it whenever leaving full-screen mode.
Sourcepub fn leave_fullscreen(&self) -> WindowOpResult
pub fn leave_fullscreen(&self) -> WindowOpResult
Attempts to leave full-screen mode.
See enter_fullscreen().
Sourcepub fn set_minimum_size(&self, size: Extent2<u32>) -> WindowOpResult
pub fn set_minimum_size(&self, size: Extent2<u32>) -> WindowOpResult
Unconditionnally prevents the window’s size from going below the given threshold.
Sourcepub fn set_maximum_size(&self, size: Extent2<u32>) -> WindowOpResult
pub fn set_maximum_size(&self, size: Extent2<u32>) -> WindowOpResult
Unconditionnally prevents the window’s size from going above the given threshold.
Sourcepub fn move_absolute(&self, pos: Extent2<u32>) -> WindowOpResult
pub fn move_absolute(&self, pos: Extent2<u32>) -> WindowOpResult
Moves the window to the given absolute position in desktop-space.
The anchor is the window’s top-left corner.
Sourcepub fn move_relative_to_self(&self, pos: Extent2<u32>) -> WindowOpResult
pub fn move_relative_to_self(&self, pos: Extent2<u32>) -> WindowOpResult
Moves the window relatively to itself in desktop-space.
The anchor is the window’s top-left corner.
Sourcepub fn move_relative_to_parent(&self, pos: Extent2<u32>) -> WindowOpResult
pub fn move_relative_to_parent(&self, pos: Extent2<u32>) -> WindowOpResult
Moves the window relatively to its parent, if any.
Otherwise, this is resolves to move_absolute().
The anchor is the window’s top-left corner.
Sourcepub fn resize(&self, size: Extent2<u32>) -> WindowOpResult
pub fn resize(&self, size: Extent2<u32>) -> WindowOpResult
Attempts to set the window’s screen-space size.