[−][src]Macro wayland_client::global_filter
Convenience macro to create a GlobalManager
callback
This macro aims to simplify the specific but common case of
providing a callback to the GlobalManager
that needs to
auto-bind all advertised instances of some specific globals
whenever they happen. Typically, your application will likely
want to keep track of all wl_seat
and wl_output
globals
to be able to correctly react to user input and their different
monitors.
The output of this macro is a closure, that can be given to
GlobalManager::new_with_cb
as the callback argument.
Example use is typically:
use wayland_client::GlobalManager; use wayland_client::protocol::{wl_output, wl_seat}; let globals = GlobalManager::new_with_cb( &display, global_filter!( // Bind all wl_seat with version 4 [wl_seat::WlSeat, 4, seat_implementor], // Bind all wl_output with version 1 [wl_output::WlOutput, 1, output_implementor] ) );
The supplied callbacks for each global kind must be an instance of a type
implementing the GlobalImplementor<I>
trait. The argument provided to your
callback is a NewProxy
of the newly instantiated global, and you should implement
it and return the implemented proxy. The error case happens if the server advertised
a lower version of the global than the one you requested, in which case you are given
the version it advertised in the error method, if you want to handle it graciously.
As with all implementations, you can also provide closures for the various callbacks, in this case the errors will be ignored. However, due to a lack of capability of rustc's inference, you'll likely need to add some type annotation to your closure, typically something like
global_filter!( [Interface, version, |new_proxy: NewProxy<_>| { ... }] );