wayland: add jay_output
This commit is contained in:
parent
6bc7330989
commit
3e3bc38920
9 changed files with 142 additions and 6 deletions
|
|
@ -4,14 +4,15 @@ use {
|
|||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{
|
||||
jay_idle::JayIdle, jay_log_file::JayLogFile, jay_screenshot::JayScreenshot,
|
||||
jay_seat_events::JaySeatEvents,
|
||||
jay_idle::JayIdle, jay_log_file::JayLogFile, jay_output::JayOutput,
|
||||
jay_screenshot::JayScreenshot, jay_seat_events::JaySeatEvents,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
screenshoter::take_screenshot,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
errorfmt::ErrorFmt,
|
||||
},
|
||||
wire::{jay_compositor::*, JayCompositorId},
|
||||
|
|
@ -225,6 +226,26 @@ impl JayCompositor {
|
|||
.insert((self.client.id, req.id), se);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_output(&self, parser: MsgParser<'_, '_>) -> Result<(), JayCompositorError> {
|
||||
let req: GetOutput = self.client.parse(self, parser)?;
|
||||
let output = self.client.lookup(req.output)?;
|
||||
let jo = Rc::new(JayOutput {
|
||||
id: req.id,
|
||||
client: self.client.clone(),
|
||||
output: CloneCell::new(output.global.node.get()),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(self.client, jo);
|
||||
self.client.add_client_obj(&jo)?;
|
||||
if let Some(node) = jo.output.get() {
|
||||
node.jay_outputs.set((self.client.id, req.id), jo.clone());
|
||||
jo.send_linear_id();
|
||||
} else {
|
||||
jo.send_destroyed();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -241,11 +262,12 @@ object_base! {
|
|||
UNLOCK => unlock,
|
||||
GET_SEATS => get_seats,
|
||||
SEAT_EVENTS => seat_events,
|
||||
GET_OUTPUT => get_output,
|
||||
}
|
||||
|
||||
impl Object for JayCompositor {
|
||||
fn num_requests(&self) -> u32 {
|
||||
SEAT_EVENTS + 1
|
||||
GET_OUTPUT + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
78
src/ifs/jay_output.rs
Normal file
78
src/ifs/jay_output.rs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
tree::OutputNode,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
wire::{jay_output::*, JayOutputId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct JayOutput {
|
||||
pub id: JayOutputId,
|
||||
pub client: Rc<Client>,
|
||||
pub output: CloneCell<Option<Rc<OutputNode>>>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl JayOutput {
|
||||
pub fn send_destroyed(&self) {
|
||||
self.client.event(Destroyed { self_id: self.id });
|
||||
}
|
||||
|
||||
pub fn send_linear_id(&self) {
|
||||
if let Some(output) = self.output.get() {
|
||||
self.client.event(LinearId {
|
||||
self_id: self.id,
|
||||
linear_id: output.id.raw(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), JayOutputError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.remove_from_node();
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_from_node(&self) {
|
||||
if let Some(output) = self.output.get() {
|
||||
output.jay_outputs.remove(&(self.client.id, self.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
JayOutput;
|
||||
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for JayOutput {
|
||||
fn num_requests(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.remove_from_node();
|
||||
}
|
||||
}
|
||||
|
||||
dedicated_add_obj!(JayOutput, JayOutputId, jay_outputs);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum JayOutputError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(JayOutputError, MsgParserError);
|
||||
efrom!(JayOutputError, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue