Skip to main content

Display

Struct Display 

Source
pub struct Display<State: 'static> { /* private fields */ }
Expand description

The Wayland display

This struct is the core of your Wayland compositor. You’ll use it in your event loop to drive the protocol processing of all your clients. All other interactions with the protocol itself are done through the DisplayHandle struct, on which the State type parameter is erased for convenience.

§Usage

The main loop of a Wayland compositor generally needs to wait on several sources of events, using tools like epoll (on Linux). The Wayland display can be integrated in this mechanism by getting the file descriptor as from .backend().poll_fd() and invoking the dispatch_clients() method whenever it becomes readable.

To ensure all clients receive the events your compositor sends them, you also need to regularly invoke the flush_clients() method, which will write the outgoing buffers into the sockets.

Implementations§

Source§

impl<State: 'static> Display<State>

Source

pub fn new() -> Result<Display<State>, InitError>

Create a new Wayland display

Can only fail if both the server_system and dlopen features of wayland-backend were enabled, and the libwayland-server.so library could not be found.

Source

pub fn handle(&self) -> DisplayHandle

Retrieve a DisplayHandle for this Display.

This is the type with which all of your interactions with the Wayland protocol are done.

Source

pub fn dispatch_clients(&mut self, state: &mut State) -> Result<usize>

Dispatch all requests received from clients to their respective callbacks.

The state argument is the main state of your compositor, which will be accessible from most of your callbacks.

Source

pub fn flush_clients(&mut self) -> Result<()>

Flush outgoing buffers into their respective sockets.

Source

pub fn backend(&mut self) -> &mut Backend<State>

Access the underlying Backend of this Display

Trait Implementations§

Source§

impl<State> AsFd for Display<State>

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Provides fd from Backend::poll_fd for polling.

Source§

impl<State: Debug + 'static> Debug for Display<State>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<State> Freeze for Display<State>

§

impl<State> RefUnwindSafe for Display<State>

§

impl<State> Send for Display<State>

§

impl<State> Sync for Display<State>

§

impl<State> Unpin for Display<State>

§

impl<State> UnsafeUnpin for Display<State>

§

impl<State> UnwindSafe for Display<State>

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>,

Source§

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>,

Source§

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.