Trait wayland_server::GlobalDispatch

source ·
pub trait GlobalDispatch<I: Resource, GlobalData, State = Self>: Sized {
    // Required method
    fn bind(
        state: &mut State,
        handle: &DisplayHandle,
        client: &Client,
        resource: New<I>,
        global_data: &GlobalData,
        data_init: &mut DataInit<'_, State>,
    );

    // Provided method
    fn can_view(_client: Client, _global_data: &GlobalData) -> bool { ... }
}
Expand description

A trait which provides an implementation for handling advertisement of a global to clients with some type of associated user data.

Its behavior is similar to the Dispatch trait.

Required Methods§

source

fn bind( state: &mut State, handle: &DisplayHandle, client: &Client, resource: New<I>, global_data: &GlobalData, data_init: &mut DataInit<'_, State>, )

Called when a client has bound this global.

The return value of this function should contain user data to associate the object created by the client.

Provided Methods§

source

fn can_view(_client: Client, _global_data: &GlobalData) -> bool

Checks if the global should be advertised to some client.

The implementation of this function determines whether a client may see and bind some global. If this function returns false, the client will not be told the global exists and attempts to bind the global will raise a protocol error.

One use of this function is implementing privileged protocols such as XWayland keyboard grabbing which must only be used by XWayland.

The default implementation allows all clients to see the global.

Object Safety§

This trait is not object safe.

Implementors§