1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
use smithay_client_toolkit::{
delegate_registry, delegate_seat,
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
seat::{Capability, SeatHandler, SeatState},
};
use wayland_client::{globals::registry_queue_init, protocol::wl_seat, Connection, QueueHandle};
fn main() {
env_logger::init();
let conn = Connection::connect_to_env().unwrap();
let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
let qh = event_queue.handle();
let mut list_seats = ListSeats {
registry_state: RegistryState::new(&globals),
seat_state: SeatState::new(&globals, &qh),
};
event_queue.blocking_dispatch(&mut list_seats).unwrap();
println!("Available seats:");
for seat in list_seats.seat_state.seats() {
if let Some(info) = list_seats.seat_state.info(&seat) {
println!("{info}");
}
}
}
struct ListSeats {
seat_state: SeatState,
registry_state: RegistryState,
}
impl SeatHandler for ListSeats {
fn seat_state(&mut self) -> &mut SeatState {
&mut self.seat_state
}
fn new_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: wl_seat::WlSeat) {
// Not applicable
}
fn new_capability(
&mut self,
_: &Connection,
_: &QueueHandle<Self>,
_: wl_seat::WlSeat,
_: Capability,
) {
// Not applicable
}
fn remove_capability(
&mut self,
_: &Connection,
_: &QueueHandle<Self>,
_: wl_seat::WlSeat,
_: Capability,
) {
// Not applicable
}
fn remove_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, _: wl_seat::WlSeat) {
// Not applicable
}
}
delegate_seat!(ListSeats);
delegate_registry!(ListSeats);
impl ProvidesRegistryState for ListSeats {
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}
registry_handlers!(SeatState);
}
|