wl_client/
test_protocol_helpers.rs1use {
2 crate::{
3 Queue,
4 test_protocols::core::{
5 wl_callback::{WlCallbackEventHandler, WlCallbackRef},
6 wl_display::WlDisplay,
7 wl_root::WlRoot,
8 },
9 },
10 parking_lot::Mutex,
11};
12
13pub struct Callback<F>(Mutex<Option<F>>);
14
15pub fn callback<F>(f: F) -> Callback<F> {
16 Callback(Mutex::new(Some(f)))
17}
18
19impl<F> WlCallbackEventHandler for Callback<F>
20where
21 F: FnOnce(),
22{
23 fn done(&self, _slf: &WlCallbackRef, _callback_data: u32) {
24 self.0.lock().take().unwrap()()
25 }
26}
27
28pub fn get_root(queue: &Queue) -> WlRoot {
29 queue.display::<WlDisplay>().get_registry().bind(0, 1)
30}