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:
$type
is the type (implementing theInterface
trait fromwayland-client
) representing a global$name
is the name of the field ofMyEnv
that is in charge of managing this global, implementing the appropriateGlobalHandler
orMultiGlobalHandler
trait
It is possible to route several globals to the same field as long as it implements all the appropriate traits.