1use {
2 crate::common::protocols::wayland::{wl_display::WlDisplay, wl_registry::WlRegistry},
3 parking_lot::Mutex,
4 wl_client::{Libwayland, Queue},
5};
6
7#[path = "../common/mod.rs"]
8mod common;
9
10fn main() {
11 let lib = Libwayland::open().unwrap();
12 let con = lib.connect_to_default_display().unwrap();
13 let queue = con.create_queue(c"get-registry");
14
15 let (_, snapshot) = get_registry_snapshot(&queue);
16 println!("{:#?}", snapshot);
17}
18
19#[expect(dead_code)]
20#[derive(Debug)]
21struct Global {
22 pub name: u32,
23 pub interface: String,
24 pub version: u32,
25}
26
27fn get_registry_snapshot(queue: &Queue) -> (WlRegistry, Vec<Global>) {
28 let registry = queue.display::<WlDisplay>().get_registry();
31 let globals = Mutex::new(vec![]);
32 queue.dispatch_scope_blocking(|scope| {
36 scope.set_event_handler(
37 ®istry,
38 WlRegistry::on_global(|_, name, interface, version| {
42 globals.lock().push(Global {
43 name,
44 interface: interface.to_string(),
45 version,
46 });
47 }),
48 );
49 queue.dispatch_roundtrip_blocking().unwrap();
50 });
51 (registry, globals.into_inner())
54}