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_output.rs
Normal file
60
src/wl_usr/usr_ifs/usr_jay_output.rs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{jay_output::*, JayOutputId},
|
||||
wl_usr::{usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub struct UsrJayOutput {
|
||||
pub id: JayOutputId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayOutputOwner>>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayOutputOwner {
|
||||
fn linear_id(self: Rc<Self>, ev: &LinearId) {
|
||||
let _ = ev;
|
||||
}
|
||||
|
||||
fn destroyed(&self) {}
|
||||
}
|
||||
|
||||
impl UsrJayOutput {
|
||||
fn linear_id(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let ev: LinearId = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.linear_id(&ev);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroyed(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let _ev: Destroyed = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.destroyed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
UsrJayOutput, JayOutput;
|
||||
|
||||
LINEAR_ID => linear_id,
|
||||
DESTROYED => destroyed,
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayOutput {
|
||||
fn destroy(&self) {
|
||||
self.con.request(Destroy { self_id: self.id });
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.set(None);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue