Macro smithay_client_toolkit::delegate_shm

source ยท
macro_rules! delegate_shm {
    ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { ... };
}
Expand description

Delegates the handling of wl_shm to some Shm.

This macro requires two things, the type that will delegate to Shm and a closure specifying how to obtain the state object.

use smithay_client_toolkit::shm::{ShmHandler, Shm};
use smithay_client_toolkit::delegate_shm;

struct ExampleApp {
    /// The state object that will be our delegate.
    shm: Shm,
}

// Use the macro to delegate wl_shm to Shm.
delegate_shm!(ExampleApp);

// You must implement the ShmHandler trait to provide a way to access the Shm from your data type.
impl ShmHandler for ExampleApp {
    fn shm_state(&mut self) -> &mut Shm {
        &mut self.shm
    }
}