Skip to main content

queue

Function queue 

Source
pub fn queue(proxy: &impl UntypedOwnedProxyWrapper) -> &Queue
Expand description

Returns the queue of a proxy.

ยงExample

let lib = Libwayland::open().unwrap();
let con = lib.connect_to_default_display().unwrap();

let queue = con.create_queue(c"");
let display: WlDisplay = queue.display();
assert_eq!(proxy::queue(&display), &*queue);
Examples found in repository?
examples/async-wait/main.rs (line 31)
24fn create_sync(queue: &Queue, n: u64) {
25    let sync = queue.display::<WlDisplay>().sync();
26    proxy::set_event_handler(
27        &sync.clone(),
28        WlCallback::on_done(move |_, _| {
29            println!("done! ({n})");
30            proxy::destroy(&sync);
31            create_sync(proxy::queue(&sync), n + 1);
32        }),
33    );
34}
More examples
Hide additional examples
examples/poll-integration/main.rs (line 58)
51fn create_sync(queue: &Queue, n: u64) {
52    let sync = queue.display::<WlDisplay>().sync();
53    proxy::set_event_handler(
54        &sync.clone(),
55        WlCallback::on_done(move |_, _| {
56            println!("done! ({n})");
57            proxy::destroy(&sync);
58            create_sync(proxy::queue(&sync), n + 1);
59        }),
60    );
61}
examples/get-registry/../common/singletons.rs (line 58)
55pub fn get_singletons(display: &WlDisplay) -> Singletons {
56    let map = Mutex::new(HashMap::new());
57
58    let queue = proxy::queue(display);
59    let wl_registry = display.get_registry();
60
61    queue.dispatch_scope_blocking(|scope| {
62        scope.set_event_handler(
63            &wl_registry,
64            WlRegistry::on_global(|_, name, interface, version| {
65                map.lock().insert(interface.to_owned(), (name, version));
66            }),
67        );
68        queue.dispatch_roundtrip_blocking().unwrap();
69    });
70
71    Singletons {
72        wl_registry,
73        map: map.into_inner(),
74    }
75}
76
77pub async fn get_singletons_async(display: &WlDisplay) -> Singletons {
78    let map = Mutex::new(HashMap::new());
79
80    let queue = proxy::queue(display);
81    let wl_registry = display.get_registry();
82
83    queue
84        .dispatch_scope_async(async |scope| {
85            scope.set_event_handler(
86                &wl_registry,
87                WlRegistry::on_global(|_, name, interface, version| {
88                    map.lock().insert(interface.to_owned(), (name, version));
89                }),
90            );
91            queue.dispatch_roundtrip_async().await.unwrap();
92        })
93        .await;
94
95    Singletons {
96        wl_registry,
97        map: map.into_inner(),
98    }
99}