autocommit 2022-04-16 13:42:13 CEST
This commit is contained in:
parent
4826305236
commit
50b792db78
27 changed files with 217 additions and 60 deletions
|
|
@ -38,6 +38,7 @@ pub(crate) struct Client {
|
|||
on_new_seat: RefCell<Option<Rc<dyn Fn(Seat)>>>,
|
||||
on_new_input_device: RefCell<Option<Rc<dyn Fn(InputDevice)>>>,
|
||||
on_connector_connected: RefCell<Option<Rc<dyn Fn(Connector)>>>,
|
||||
on_graphics_initialized: Cell<Option<Box<dyn FnOnce()>>>,
|
||||
on_new_connector: RefCell<Option<Rc<dyn Fn(Connector)>>>,
|
||||
bufs: RefCell<Vec<Vec<u8>>>,
|
||||
}
|
||||
|
|
@ -120,6 +121,7 @@ pub unsafe extern "C" fn init(
|
|||
on_new_seat: Default::default(),
|
||||
on_new_input_device: Default::default(),
|
||||
on_connector_connected: Default::default(),
|
||||
on_graphics_initialized: Default::default(),
|
||||
on_new_connector: Default::default(),
|
||||
bufs: Default::default(),
|
||||
});
|
||||
|
|
@ -411,6 +413,10 @@ impl Client {
|
|||
*self.on_connector_connected.borrow_mut() = Some(Rc::new(f));
|
||||
}
|
||||
|
||||
pub fn on_graphics_initialized<F: FnOnce() + 'static>(&self, f: F) {
|
||||
self.on_graphics_initialized.set(Some(Box::new(f)));
|
||||
}
|
||||
|
||||
pub fn set_seat(&self, device: InputDevice, seat: Seat) {
|
||||
self.send(&ClientMessage::SetSeat { device, seat })
|
||||
}
|
||||
|
|
@ -551,6 +557,11 @@ impl Client {
|
|||
handler();
|
||||
}
|
||||
}
|
||||
ServerMessage::GraphicsInitialized => {
|
||||
if let Some(handler) = self.on_graphics_initialized.take() {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use {
|
|||
#[derive(Encode, BorrowDecode, Debug)]
|
||||
pub enum ServerMessage {
|
||||
Configure,
|
||||
GraphicsInitialized,
|
||||
Response {
|
||||
response: Response,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -96,6 +96,10 @@ pub fn on_connector_connected<F: Fn(Connector) + 'static>(f: F) {
|
|||
get!().on_connector_connected(f)
|
||||
}
|
||||
|
||||
pub fn on_graphics_initialized<F: FnOnce() + 'static>(f: F) {
|
||||
get!().on_graphics_initialized(f)
|
||||
}
|
||||
|
||||
pub fn get_connector(id: impl ToConnectorId) -> Connector {
|
||||
let (ty, idx) = match id.to_connector_id() {
|
||||
Ok(id) => id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue