get_registry_with_data/
main.rs1use {
2 crate::common::protocols_data::wayland::{wl_display::WlDisplay, wl_registry::WlRegistry},
3 wl_client::{Libwayland, proxy},
4};
5
6#[path = "../common/mod.rs"]
7mod common;
8
9struct State {
10 registry: WlRegistry,
11 globals: Vec<Global>,
12}
13
14#[expect(dead_code)]
15#[derive(Debug)]
16struct Global {
17 name: u32,
18 interface: String,
19 version: u32,
20}
21
22fn main() {
23 let lib = Libwayland::open().unwrap();
24 let con = lib.connect_to_default_display().unwrap();
25 let (_queue, queue) = con.create_queue_with_data::<State>(c"get-registry");
26
27 let mut state = State {
30 registry: queue.display::<WlDisplay>().get_registry(),
31 globals: vec![],
32 };
33
34 proxy::set_event_handler(
38 &state.registry,
39 WlRegistry::on_global(|state: &mut State, _, name, interface, version| {
40 state.globals.push(Global {
41 name,
42 interface: interface.to_string(),
43 version,
44 });
45 }),
46 );
47 queue.dispatch_roundtrip_blocking(&mut state).unwrap();
48
49 println!("{:#?}", state.globals);
50}