wayland: implement surface transformations
- buffer scale - buffer transform - viewporter
This commit is contained in:
parent
20f0fba553
commit
95327685c1
16 changed files with 635 additions and 75 deletions
104
src/ifs/wp_viewporter.rs
Normal file
104
src/ifs/wp_viewporter.rs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::wl_surface::wp_viewport::{WpViewport, WpViewportError},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wp_viewporter::*, WpViewporterId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct WpViewporterGlobal {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
impl WpViewporterGlobal {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: WpViewporterId,
|
||||
client: &Rc<Client>,
|
||||
_version: u32,
|
||||
) -> Result<(), WpViewporterError> {
|
||||
let obj = Rc::new(WpViewporter {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(WpViewporterGlobal, WpViewporter, WpViewporterError);
|
||||
|
||||
impl Global for WpViewporterGlobal {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(WpViewporterGlobal);
|
||||
|
||||
pub struct WpViewporter {
|
||||
pub id: WpViewporterId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl WpViewporter {
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewporterError> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_viewport(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewporterError> {
|
||||
let req: GetViewport = self.client.parse(self, msg)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let viewport = Rc::new(WpViewport::new(req.id, &surface));
|
||||
track!(self.client, viewport);
|
||||
viewport.install()?;
|
||||
self.client.add_client_obj(&viewport)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
WpViewporter;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_VIEWPORT => get_viewport,
|
||||
}
|
||||
|
||||
impl Object for WpViewporter {
|
||||
fn num_requests(&self) -> u32 {
|
||||
GET_VIEWPORT + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(WpViewporter);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpViewporterError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WpViewportError(#[from] WpViewportError),
|
||||
}
|
||||
efrom!(WpViewporterError, MsgParserError);
|
||||
efrom!(WpViewporterError, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue