feat(examples): add Wayland globals lister utility
Minimal example that connects to the Wayland compositor and prints all advertised globals (interface name, ID, version).
This commit is contained in:
26
examples/list_globals.rs
Normal file
26
examples/list_globals.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use wayland_client::globals::registry_queue_init;
|
||||||
|
use wayland_client::globals::GlobalListContents;
|
||||||
|
use wayland_client::protocol::wl_registry::{Event, WlRegistry};
|
||||||
|
use wayland_client::{Connection, Dispatch, QueueHandle};
|
||||||
|
|
||||||
|
struct Ls;
|
||||||
|
|
||||||
|
impl Dispatch<WlRegistry, GlobalListContents> for Ls {
|
||||||
|
fn event(
|
||||||
|
_state: &mut Self,
|
||||||
|
_registry: &WlRegistry,
|
||||||
|
_event: Event,
|
||||||
|
_data: &GlobalListContents,
|
||||||
|
_conn: &Connection,
|
||||||
|
_qhandle: &QueueHandle<Self>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let conn = Connection::connect_to_env().unwrap();
|
||||||
|
let (globals, _queue) = registry_queue_init::<Ls>(&conn).unwrap();
|
||||||
|
for g in globals.contents().clone_list() {
|
||||||
|
println!("{}: {} v{}", g.name, g.interface, g.version);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user