-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from mahkoh/jorth/jay-tray
wayland: implement jay-tray-v1
- Loading branch information
Showing
33 changed files
with
1,025 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
use { | ||
crate::{ | ||
client::{Client, ClientError}, | ||
globals::{Global, GlobalName, RemovableWaylandGlobal}, | ||
ifs::{ | ||
wl_output::OutputGlobalOpt, | ||
wl_surface::tray::jay_tray_item_v1::{JayTrayItemV1, JayTrayItemV1Error}, | ||
}, | ||
leaks::Tracker, | ||
object::{Object, Version}, | ||
wire::{jay_tray_v1::*, JayTrayV1Id}, | ||
}, | ||
std::rc::Rc, | ||
thiserror::Error, | ||
}; | ||
|
||
pub struct JayTrayV1Global { | ||
pub name: GlobalName, | ||
pub output: Rc<OutputGlobalOpt>, | ||
} | ||
|
||
pub struct JayTrayV1 { | ||
pub id: JayTrayV1Id, | ||
pub client: Rc<Client>, | ||
pub tracker: Tracker<Self>, | ||
pub version: Version, | ||
pub output: Rc<OutputGlobalOpt>, | ||
} | ||
|
||
impl JayTrayV1Global { | ||
fn bind_( | ||
self: Rc<Self>, | ||
id: JayTrayV1Id, | ||
client: &Rc<Client>, | ||
version: Version, | ||
) -> Result<(), JayTrayManagerV1Error> { | ||
let obj = Rc::new(JayTrayV1 { | ||
id, | ||
client: client.clone(), | ||
tracker: Default::default(), | ||
version, | ||
output: self.output.clone(), | ||
}); | ||
track!(client, obj); | ||
client.add_client_obj(&obj)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
global_base!(JayTrayV1Global, JayTrayV1, JayTrayManagerV1Error); | ||
|
||
impl Global for JayTrayV1Global { | ||
fn singleton(&self) -> bool { | ||
false | ||
} | ||
|
||
fn version(&self) -> u32 { | ||
1 | ||
} | ||
} | ||
|
||
simple_add_global!(JayTrayV1Global); | ||
|
||
impl RemovableWaylandGlobal for JayTrayV1Global { | ||
fn create_replacement(self: Rc<Self>) -> Rc<dyn Global> { | ||
self | ||
} | ||
} | ||
|
||
impl JayTrayV1RequestHandler for JayTrayV1 { | ||
type Error = JayTrayManagerV1Error; | ||
|
||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
self.client.remove_obj(self)?; | ||
Ok(()) | ||
} | ||
|
||
fn get_tray_item(&self, req: GetTrayItem, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
let surface = self.client.lookup(req.surface)?; | ||
let fs = Rc::new(JayTrayItemV1::new( | ||
req.id, | ||
self.version, | ||
&surface, | ||
&self.output, | ||
)); | ||
track!(self.client, fs); | ||
fs.install()?; | ||
self.client.add_client_obj(&fs)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
object_base! { | ||
self = JayTrayV1; | ||
version = self.version; | ||
} | ||
|
||
impl Object for JayTrayV1 {} | ||
|
||
simple_add_obj!(JayTrayV1); | ||
|
||
#[derive(Debug, Error)] | ||
pub enum JayTrayManagerV1Error { | ||
#[error(transparent)] | ||
ClientError(Box<ClientError>), | ||
#[error(transparent)] | ||
ExtTrayItemV1Error(#[from] JayTrayItemV1Error), | ||
} | ||
efrom!(JayTrayManagerV1Error, ClientError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.