wayland: add a generic wayland client
This commit is contained in:
parent
163adbd893
commit
2512470231
34 changed files with 2627 additions and 1 deletions
60
src/wl_usr/usr_ifs/usr_jay_render_ctx.rs
Normal file
60
src/wl_usr/usr_ifs/usr_jay_render_ctx.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{jay_render_ctx::*, JayRenderCtxId},
|
||||
wl_usr::{usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::rc::Rc,
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct UsrJayRenderCtx {
|
||||
pub id: JayRenderCtxId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayRenderCtxOwner>>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayRenderCtxOwner {
|
||||
fn no_device(&self) {}
|
||||
fn device(&self, fd: Rc<OwnedFd>) {
|
||||
let _ = fd;
|
||||
}
|
||||
}
|
||||
|
||||
impl UsrJayRenderCtx {
|
||||
fn no_device(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let _ev: NoDevice = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.no_device();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn device(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let ev: Device = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.device(ev.fd);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
UsrJayRenderCtx, JayRenderCtx;
|
||||
|
||||
NO_DEVICE => no_device,
|
||||
DEVICE => device,
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayRenderCtx {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue