portal: implement window capture
This commit is contained in:
parent
f0600917ff
commit
4e10415e5c
27 changed files with 840 additions and 136 deletions
|
|
@ -3,6 +3,8 @@ pub mod usr_jay_output;
|
|||
pub mod usr_jay_pointer;
|
||||
pub mod usr_jay_render_ctx;
|
||||
pub mod usr_jay_screencast;
|
||||
pub mod usr_jay_select_toplevel;
|
||||
pub mod usr_jay_toplevel;
|
||||
pub mod usr_jay_workspace;
|
||||
pub mod usr_jay_workspace_watcher;
|
||||
pub mod usr_linux_buffer_params;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use {
|
|||
usr_ifs::{
|
||||
usr_jay_output::UsrJayOutput, usr_jay_pointer::UsrJayPointer,
|
||||
usr_jay_render_ctx::UsrJayRenderCtx, usr_jay_screencast::UsrJayScreencast,
|
||||
usr_jay_select_toplevel::UsrJaySelectToplevel,
|
||||
usr_jay_workspace_watcher::UsrJayWorkspaceWatcher, usr_wl_output::UsrWlOutput,
|
||||
usr_wl_seat::UsrWlSeat,
|
||||
},
|
||||
|
|
@ -17,13 +18,14 @@ use {
|
|||
UsrCon,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct UsrJayCompositor {
|
||||
pub id: JayCompositorId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayCompositorOwner>>>,
|
||||
pub window_capture: Cell<bool>,
|
||||
}
|
||||
|
||||
pub trait UsrJayCompositorOwner {
|
||||
|
|
@ -112,6 +114,21 @@ impl UsrJayCompositor {
|
|||
jp
|
||||
}
|
||||
|
||||
pub fn select_toplevel(&self, seat: &UsrWlSeat) -> Rc<UsrJaySelectToplevel> {
|
||||
let sc = Rc::new(UsrJaySelectToplevel {
|
||||
id: self.con.id(),
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
});
|
||||
self.con.request(SelectToplevel {
|
||||
self_id: self.id,
|
||||
id: sc.id,
|
||||
seat: seat.id,
|
||||
});
|
||||
self.con.add_object(sc.clone());
|
||||
sc
|
||||
}
|
||||
|
||||
fn client_id(&self, parser: MsgParser<'_, '_>) -> Result<(), MsgParserError> {
|
||||
let ev: ClientId = self.con.parse(self, parser)?;
|
||||
if let Some(owner) = self.owner.get() {
|
||||
|
|
@ -133,6 +150,7 @@ impl UsrJayCompositor {
|
|||
for &cap in ev.cap {
|
||||
match cap {
|
||||
Cap::NONE => {}
|
||||
Cap::WINDOW_CAPTURE => self.window_capture.set(true),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@ use {
|
|||
},
|
||||
video::dmabuf::{DmaBuf, DmaBufPlane, PlaneVec},
|
||||
wire::{jay_screencast::*, JayScreencastId},
|
||||
wl_usr::{usr_ifs::usr_jay_output::UsrJayOutput, usr_object::UsrObject, UsrCon},
|
||||
wl_usr::{
|
||||
usr_ifs::{usr_jay_output::UsrJayOutput, usr_jay_toplevel::UsrJayToplevel},
|
||||
usr_object::UsrObject,
|
||||
UsrCon,
|
||||
},
|
||||
},
|
||||
std::{cell::RefCell, mem, ops::DerefMut, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
@ -60,6 +64,13 @@ impl UsrJayScreencast {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn set_toplevel(&self, tl: &UsrJayToplevel) {
|
||||
self.con.request(SetToplevel {
|
||||
self_id: self.id,
|
||||
id: tl.id,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn set_allow_all_workspaces(&self, allow_all: bool) {
|
||||
self.con.request(SetAllowAllWorkspaces {
|
||||
self_id: self.id,
|
||||
|
|
|
|||
71
src/wl_usr/usr_ifs/usr_jay_select_toplevel.rs
Normal file
71
src/wl_usr/usr_ifs/usr_jay_select_toplevel.rs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{jay_select_toplevel::*, JaySelectToplevelId},
|
||||
wl_usr::{usr_ifs::usr_jay_toplevel::UsrJayToplevel, usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct UsrJaySelectToplevel {
|
||||
pub id: JaySelectToplevelId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJaySelectToplevelOwner>>>,
|
||||
}
|
||||
|
||||
pub trait UsrJaySelectToplevelOwner {
|
||||
fn done(&self, toplevel: Option<Rc<UsrJayToplevel>>);
|
||||
}
|
||||
|
||||
impl UsrJaySelectToplevel {
|
||||
fn done(&self, parser: MsgParser<'_, '_>) -> Result<(), UsrJaySelectToplevelError> {
|
||||
let ev: Done = self.con.parse(self, parser)?;
|
||||
let tl = if ev.id.is_none() {
|
||||
None
|
||||
} else {
|
||||
let tl = Rc::new(UsrJayToplevel {
|
||||
id: ev.id,
|
||||
con: self.con.clone(),
|
||||
owner: Default::default(),
|
||||
});
|
||||
self.con.add_object(tl.clone());
|
||||
Some(tl)
|
||||
};
|
||||
match self.owner.get() {
|
||||
Some(owner) => owner.done(tl),
|
||||
_ => {
|
||||
if let Some(tl) = tl {
|
||||
self.con.remove_obj(&*tl);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.con.remove_obj(self);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
usr_object_base! {
|
||||
UsrJaySelectToplevel, JaySelectToplevel;
|
||||
|
||||
DONE => done,
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJaySelectToplevel {
|
||||
fn destroy(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.owner.take();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum UsrJaySelectToplevelError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[from] MsgParserError),
|
||||
}
|
||||
47
src/wl_usr/usr_ifs/usr_jay_toplevel.rs
Normal file
47
src/wl_usr/usr_ifs/usr_jay_toplevel.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{jay_toplevel::*, JayToplevelId},
|
||||
wl_usr::{usr_object::UsrObject, UsrCon},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub struct UsrJayToplevel {
|
||||
pub id: JayToplevelId,
|
||||
pub con: Rc<UsrCon>,
|
||||
pub owner: CloneCell<Option<Rc<dyn UsrJayToplevelOwner>>>,
|
||||
}
|
||||
|
||||
pub trait UsrJayToplevelOwner {
|
||||
fn destroyed(&self) {}
|
||||
}
|
||||
|
||||
impl UsrJayToplevel {
|
||||
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! {
|
||||
UsrJayToplevel, JayToplevel;
|
||||
|
||||
DESTROYED => destroyed,
|
||||
}
|
||||
|
||||
impl UsrObject for UsrJayToplevel {
|
||||
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