1
0
Fork 0
forked from wry/wry

autocommit 2022-02-05 18:14:24 CET

This commit is contained in:
Julian Orth 2022-02-05 18:14:24 +01:00
parent 2d8b3a200e
commit 3a4ae99b9a
71 changed files with 1626 additions and 1306 deletions

View file

@ -3,7 +3,7 @@ mod types;
use crate::client::{Client, DynEventFormatter};
use crate::ifs::wl_callback::WlCallback;
use crate::ifs::wl_registry::WlRegistry;
use crate::object::{Interface, Object, ObjectId, WL_DISPLAY_ID};
use crate::object::{Object, ObjectId, WL_DISPLAY_ID};
use crate::utils::buffd::MsgParser;
use std::rc::Rc;
pub use types::*;
@ -21,29 +21,18 @@ const NO_MEMORY: u32 = 2;
const IMPLEMENTATION: u32 = 3;
pub struct WlDisplay {
id: ObjectId,
client: Rc<Client>,
}
impl WlDisplay {
pub fn new(client: &Rc<Client>) -> Self {
Self {
id: WL_DISPLAY_ID,
client: client.clone(),
}
}
fn handle_request_(
&self,
request: u32,
parser: MsgParser<'_, '_>,
) -> Result<(), WlDisplayError> {
match request {
SYNC => self.sync(parser)?,
GET_REGISTRY => self.get_registry(parser)?,
_ => unreachable!(),
}
Ok(())
}
fn sync(&self, parser: MsgParser<'_, '_>) -> Result<(), SyncError> {
let sync: Sync = self.client.parse(self, parser)?;
let cb = Rc::new(WlCallback::new(sync.callback));
@ -106,17 +95,14 @@ impl WlDisplay {
}
}
handle_request!(WlDisplay);
object_base! {
WlDisplay, WlDisplayError;
SYNC => sync,
GET_REGISTRY => get_registry,
}
impl Object for WlDisplay {
fn id(&self) -> ObjectId {
WL_DISPLAY_ID
}
fn interface(&self) -> Interface {
Interface::WlDisplay
}
fn num_requests(&self) -> u32 {
GET_REGISTRY + 1
}