Macro smithay_client_toolkit::environment
source · macro_rules! environment { ($env_name:ident, singles = [$($sty:ty => $sname:ident),* $(,)?], multis = [$($mty:ty => $mname:ident),* $(,)?]$(,)? ) => { ... }; }
Expand description
Macro for declaring an environment
It needs to be used in conjunction with a a struct you declared, which will serve as the inner
environment and hold the handlers for your globals.
The macro is invoked as such:
struct MyEnv {
compositor: SimpleGlobal<WlCompositor>,
subcompositor: SimpleGlobal<WlSubcompositor>,
outputs: OutputHandler
}
environment!(MyEnv,
singles = [
WlCompositor => compositor,
WlSubcompositor => subcompositor,
],
multis = [
WlOutput => outputs,
]
);This will define how your MyEnv struct is able to manage the WlCompositor, WlSubcompositor and
WlOutput globals. For each global, you need to provide a pattern
$type => $name where:
$typeis the type (implementing theInterfacetrait fromwayland-client) representing a global$nameis the name of the field ofMyEnvthat is in charge of managing this global, implementing the appropriateGlobalHandlerorMultiGlobalHandlertrait
It is possible to route several globals to the same field as long as it implements all the appropriate traits.