1use {
2 crate::common::protocols::wayland::{wl_display::WlDisplay, wl_registry::WlRegistry},
3 std::cell::Cell,
4 wl_client::Libwayland,
5};
6
7#[path = "../common/mod.rs"]
8mod common;
9
10#[tokio::main(flavor = "current_thread")]
11async fn main() {
12 let lib = Libwayland::open().unwrap();
13 let con = lib.connect_to_default_display().unwrap();
14 let queue = con.create_local_queue(c"async-roundtrip");
15 let registry = queue.display::<WlDisplay>().get_registry();
16 let num_globals = Cell::new(0);
17 queue
18 .dispatch_scope_async(async |scope| {
19 scope.set_event_handler_local(
20 ®istry,
21 WlRegistry::on_global(|_, _, _, _| {
22 num_globals.set(num_globals.get() + 1);
23 }),
24 );
25 queue.dispatch_roundtrip_async().await.unwrap();
29 })
30 .await;
31 println!("number of globals: {}", num_globals.get());
32}