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