wayland: add a generic wayland client
This commit is contained in:
parent
163adbd893
commit
2512470231
34 changed files with 2627 additions and 1 deletions
47
src/wl_usr/usr_ifs/usr_wl_buffer.rs
Normal file
47
src/wl_usr/usr_ifs/usr_wl_buffer.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{wl_buffer::*, WlBufferId},
|
||||
wl_usr::{usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub struct UsrWlBuffer {
|
||||
pub id: WlBufferId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrWlBufferOwner>>>,
|
||||
}
|
||||
|
||||
pub trait UsrWlBufferOwner {
|
||||
fn release(&self) {}
|
||||
}
|
||||
|
||||
impl UsrWlBuffer {
|
||||
fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let _ev: Release = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
owner.release();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
UsrWlBuffer, WlBuffer;
|
||||
|
||||
RELEASE => release,
|
||||
}
|
||||
|
||||
impl UsrObject for UsrWlBuffer {
|
||||
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