wayland_client::wayland_env! [] [src]

macro_rules! wayland_env {
    ($structname: ident, $($name: ident : $interface: ty),*) => { ... };
}

This macro allows you to create a simple wayland environment handler.

It will define a struct which upon creation communicates with the server to fetch the list of global objects and instanciate them with the newest interface version supported by both the server and the client library.

This struct comes with a static constructor init(display), which takes a display, and returns the created struct and an EventIterator associated with the display and all the global objects.

Note that none of the events associated with the newly created objects are dispatched (expect for the registry), allowing you to change the event iterators associated with them before dispatching them, if you want to.

The struct has these public fields:

Note that:

The struct also provides two methods:

Example of use:

#[macro_use] extern crate wayland_client;

use wayland_client::wayland::get_display;
use wayland_client::wayland::compositor::WlCompositor;
use wayland_client::wayland::shell::WlShell;

wayland_env!(WaylandEnv,
    compositor: WlCompositor,
    shell: WlShell
);

fn main() {
    let display = get_display().expect("Unable to connect to waylans server.");
    let (env, iter) = WaylandEnv::init(display);
    let shell = match env.shell {
        Some((ref comp, version)) if version >= 2 => comp,
        _ => panic!("This app requires the wayland interface wl_shell of version >= 2.")
    };
    // etc...
}