pub struct Window<F: Frame> { /* private fields */ }
Expand description

A window

This wrapper handles for you the decoration of your window and the interaction with the server regarding the shell protocol.

You are still entirely responsible for drawing the contents of your window.

Note also that as the dimensions of wayland surfaces is defined by their attached buffer, you need to keep the decorations in sync with your contents via the resize(..) method.

Different kind of decorations can be used by customizing the type parameter. A few are provided in this crate if the frames cargo feature is enabled, but any type implementing the Frame trait can do.

Implementations§

source§

impl<F: Frame + 'static> Window<F>

source

pub fn surface(&self) -> &WlSurface

Access the surface wrapped in this Window

source

pub fn refresh(&mut self)

Refreshes the frame

Redraws the frame to match its requested state (dimensions, presence/ absence of decorations, …)

You need to call this method after every change to the dimensions or state of the decorations of your window, otherwise the drawn decorations may go out of sync with the state of your content.

Your implementation will also receive Refresh events when the frame requests to be redrawn (to provide some frame animations for example).

source

pub fn set_title(&self, title: String)

Set a short title for the window.

This string may be used to identify the surface in a task bar, window list, or other user interface elements provided by the compositor.

You need to call refresh() afterwards for this to properly take effect.

source

pub fn set_app_id(&self, app_id: String)

Set an app id for the surface.

The surface class identifies the general class of applications to which the surface belongs.

Several wayland compositors will try to find a .desktop file matching this name to find metadata about your apps.

source

pub fn set_decorate(&mut self, decorate: Decorations)

Set whether the window should be decorated or not.

If zxdg_toplevel_decoration_v1 object is presented and alive, requesting None decorations will result in setting ClientSide decorations with hidden frame, and if ClientSide decorations were requested, it’ll result in destroying zxdg_toplevel_decoration_v1 object, meaning that you won’t be able to get ServerSide decorations back.

In case zxdg_toplevel_decoration_v1 is not available or the corresponding object is not alive anymore, decorate with ServerSide or FollowServer values will always result in ClientSide decorations being used.

You need to call refresh() afterwards for this to properly take effect.

source

pub fn set_resizable(&self, resizable: bool)

Set whether the window should be resizeable by the user

This is not an hard blocking, as the compositor can always resize you forcibly if it wants. However it signals it that you don’t want this window to be resized.

Additionally, the decorations will stop suggesting the user to resize by dragging the borders if you set the window as non-resizable.

When re-activating resizability, any previously set min/max sizes are restored.

source

pub fn resize(&mut self, w: u32, h: u32)

Resize the decorations

You should call this whenever you change the size of the contents of your window, with the new inner size of your window.

This size is expressed in logical pixels, like the one received in Event::Configure.

You need to call refresh() afterwards for this to properly take effect.

source

pub fn set_maximized(&self)

Request the window to be maximized

source

pub fn unset_maximized(&self)

Request the window to be un-maximized

source

pub fn set_minimized(&self)

Request the window to be minimized

source

pub fn set_fullscreen(&self, output: Option<&WlOutput>)

Request the window to be set fullscreen

Note: The decorations hiding behavior is Frame dependant. To check whether you need to hide them consult your frame documentation.

source

pub fn unset_fullscreen(&self)

Request the window to quit fullscreen mode

source

pub fn set_min_size(&mut self, size: Option<(u32, u32)>)

Sets the minimum possible size for this window

Provide either a tuple Some((width, height)) or None to unset the minimum size.

Setting either value in the tuple to 0 means that this axis should not be limited.

The provided size is the interior size, not counting decorations.

This size is expressed in logical pixels, like the one received in Event::Configure.

source

pub fn set_max_size(&mut self, size: Option<(u32, u32)>)

Sets the maximum possible size for this window

Provide either a tuple Some((width, height)) or None to unset the maximum size.

Setting either value in the tuple to 0 means that this axis should not be limited.

The provided size is the interior size, not counting decorations.

This size is expressed in logical pixels, like the one received in Event::Configure.

source

pub fn set_frame_config(&mut self, config: F::Config)

Sets the frame configuration for the window

This allows to configure the frame at runtime if it supports it. See the documentation of your Frame implementation for details about what configuration it supports.

source

pub fn start_interactive_move(&self, seat: &WlSeat, serial: u32)

Start an interactive, user-driven move of the surface

This request must be used in response to some sort of user action like a button press, key press, or touch down event. The passed serial is used to determine the type of interactive move (touch, pointer, etc).

The server may ignore move requests depending on the state of the surface (e.g. fullscreen or maximized), or if the passed serial is no longer valid.

Trait Implementations§

source§

impl<F> Debug for Window<F>
where F: Debug + Frame,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F: Frame> Drop for Window<F>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for Window<F>

§

impl<F> !Send for Window<F>

§

impl<F> !Sync for Window<F>

§

impl<F> Unpin for Window<F>

§

impl<F> !UnwindSafe for Window<F>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.