1
0
Fork 0
forked from wry/wry

portal: implement RemoteDesktop portal

This commit is contained in:
Julian Orth 2024-07-24 17:57:48 +02:00
parent 40e87f8f91
commit 665127e6c0
22 changed files with 994 additions and 35 deletions

View file

@ -1,4 +1,6 @@
pub mod usr_jay_compositor;
pub mod usr_jay_ei_session;
pub mod usr_jay_ei_session_builder;
pub mod usr_jay_output;
pub mod usr_jay_pointer;
pub mod usr_jay_render_ctx;

View file

@ -6,8 +6,9 @@ use {
wire::{jay_compositor::*, JayCompositorId},
wl_usr::{
usr_ifs::{
usr_jay_output::UsrJayOutput, usr_jay_pointer::UsrJayPointer,
usr_jay_render_ctx::UsrJayRenderCtx, usr_jay_screencast::UsrJayScreencast,
usr_jay_ei_session_builder::UsrJayEiSessionBuilder, usr_jay_output::UsrJayOutput,
usr_jay_pointer::UsrJayPointer, usr_jay_render_ctx::UsrJayRenderCtx,
usr_jay_screencast::UsrJayScreencast,
usr_jay_select_toplevel::UsrJaySelectToplevel,
usr_jay_select_workspace::UsrJaySelectWorkspace,
usr_jay_workspace_watcher::UsrJayWorkspaceWatcher, usr_wl_output::UsrWlOutput,
@ -156,6 +157,20 @@ impl UsrJayCompositor {
self.con.add_object(sc.clone());
sc
}
pub fn create_ei_session(&self) -> Rc<UsrJayEiSessionBuilder> {
let obj = Rc::new(UsrJayEiSessionBuilder {
id: self.con.id(),
con: self.con.clone(),
version: self.version,
});
self.con.request(CreateEiSession {
self_id: self.id,
id: obj.id,
});
self.con.add_object(obj.clone());
obj
}
}
impl JayCompositorEventHandler for UsrJayCompositor {

View file

@ -0,0 +1,72 @@
use {
crate::{
object::Version,
utils::clonecell::CloneCell,
wire::{
jay_ei_session::{Created, Destroyed, Failed, JayEiSessionEventHandler, Release},
JayEiSessionId,
},
wl_usr::{usr_object::UsrObject, UsrCon},
},
std::{convert::Infallible, rc::Rc},
uapi::OwnedFd,
};
pub struct UsrJayEiSession {
pub id: JayEiSessionId,
pub con: Rc<UsrCon>,
pub owner: CloneCell<Option<Rc<dyn UsrJayEiSessionOwner>>>,
pub version: Version,
}
pub trait UsrJayEiSessionOwner {
fn destroyed(&self) {}
fn created(&self, fd: &Rc<OwnedFd>) {
let _ = fd;
}
fn failed(&self, reason: &str) {
let _ = reason;
}
}
impl JayEiSessionEventHandler for UsrJayEiSession {
type Error = Infallible;
fn destroyed(&self, _ev: Destroyed, _slf: &Rc<Self>) -> Result<(), Self::Error> {
if let Some(owner) = self.owner.get() {
owner.destroyed();
}
Ok(())
}
fn created(&self, ev: Created, _slf: &Rc<Self>) -> Result<(), Self::Error> {
if let Some(owner) = self.owner.get() {
owner.created(&ev.fd);
}
Ok(())
}
fn failed(&self, ev: Failed<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
if let Some(owner) = self.owner.get() {
owner.failed(ev.reason);
}
Ok(())
}
}
usr_object_base! {
self = UsrJayEiSession = JayEiSession;
version = self.version;
}
impl UsrObject for UsrJayEiSession {
fn destroy(&self) {
self.con.request(Release { self_id: self.id });
}
fn break_loops(&self) {
self.owner.take();
}
}

View file

@ -0,0 +1,57 @@
use {
crate::{
object::Version,
wire::{
jay_ei_session_builder::{Commit, JayEiSessionBuilderEventHandler, SetAppId},
JayEiSessionBuilderId,
},
wl_usr::{usr_ifs::usr_jay_ei_session::UsrJayEiSession, usr_object::UsrObject, UsrCon},
},
std::{convert::Infallible, rc::Rc},
};
pub struct UsrJayEiSessionBuilder {
pub id: JayEiSessionBuilderId,
pub con: Rc<UsrCon>,
pub version: Version,
}
impl UsrJayEiSessionBuilder {
pub fn set_app_id(&self, app_id: &str) {
self.con.request(SetAppId {
self_id: self.id,
app_id,
});
}
pub fn commit(&self) -> Rc<UsrJayEiSession> {
let obj = Rc::new(UsrJayEiSession {
id: self.con.id(),
con: self.con.clone(),
owner: Default::default(),
version: self.version,
});
self.con.add_object(obj.clone());
self.con.request(Commit {
self_id: self.id,
id: obj.id,
});
self.con.remove_obj(self);
obj
}
}
impl JayEiSessionBuilderEventHandler for UsrJayEiSessionBuilder {
type Error = Infallible;
}
usr_object_base! {
self = UsrJayEiSessionBuilder = JayEiSessionBuilder;
version = self.version;
}
impl UsrObject for UsrJayEiSessionBuilder {
fn destroy(&self) {
// nothing
}
}