[][src]Macro smithay_client_toolkit::environment

macro_rules! environment {
    ($env_name:ident,
        singles = [$($sty:ty => $sname:ident),* $(,)?],
        multis = [$($mty:ty => $mname:ident),* $(,)?]$(,)?
    ) => { ... };
}

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:

It is possible to route several globals to the same field as long as it implements all the appropriate traits.