Macro wayland_client::event_created_child
source · macro_rules! event_created_child { ($(@< $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ >)? $selftype:ty, $iface:ty, [$($opcode:pat => ($child_iface:ty, $child_udata:expr)),* $(,)?]) => { ... }; }
Expand description
Macro used to override Dispatch::event_created_child()
Use this macro inside the Dispatch
implementation to override this method, to implement the
initialization of the user data for event-created objects. The usage syntax is as follow:
ⓘ
impl Dispatch<WlFoo, FooUserData> for MyState {
fn event(
&mut self,
proxy: &WlFoo,
event: FooEvent,
data: &FooUserData,
connhandle: &mut ConnectionHandle,
qhandle: &QueueHandle<MyState>
) {
/* ... */
}
event_created_child!(MyState, WlFoo, [
// there can be multiple lines if this interface has multiple object-creating event
EVT_CREATE_BAR => (WlBar, BarUserData::new()),
// ~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~~~~~
// | | |
// | | +-- an expression whose evaluation produces the
// | | user data value
// | +-- the type of the newly created object
// +-- the opcode of the event that creates a new object, constants for those are
// generated alongside the `WlFoo` type in the `wl_foo` module
]);
}