Macro wayland_client::wayland_env
[−]
[src]
macro_rules! wayland_env { (pub $name: ident) => { ... }; (pub $name: ident, $($global_name: ident : $global_type: path),+) => { ... }; ($name: ident) => { ... }; ($name: ident, $($global_name: ident : $global_type: path),+) => { ... }; (__impl $name: ident, $($global_name: ident : $global_type: path),+) => { ... }; }
Create an environment handling struct
To be used in conjunction with the EnvHandler
utility.
Declare the globals your application needs to use, like this, following the
general pattern: $name : $type
:
use wayland_client::protocol::{Wl_compositor,wl_shell}; wayland_env!(WaylandEnv, compositor: wl_compositor::WlCompositor, shell : wl_shell::WlShell );
$name
(compositor
and shell
in this example) are the name of the
fields that will contain the global objects one initialisation is done.
$type
must be a wayland object type, implementing the Proxy
trait.
If more than one field with a given type are provided, the handler will expect
the server to declare as many global objects of given type. If more globals of
a given type are declared by the server than in this macro, only the first N
will be bound in the environment struct.
This utility will interpret all globals declared in this macro as necessary, and
thus will not give you access to anything util they have all been declared by the compositor.
As such, only declare globals that your application cannot run without, like probably
wl_compositor
, wl_shm
or wl_seat
. If there are globals that you can optionnaly
use, you'll have to instantiate them manually via WlRegistry::bind(..)
.