1
0
Fork 0
forked from wry/wry

xwayland: add x-surface indirection

This commit is contained in:
Julian Orth 2022-10-16 20:53:59 +02:00
parent 8059457afb
commit 6193569596
6 changed files with 123 additions and 66 deletions

View file

@ -0,0 +1,53 @@
use {
crate::{
ifs::wl_surface::{x_surface::xwindow::Xwindow, SurfaceExt, WlSurface, WlSurfaceError},
leaks::Tracker,
tree::ToplevelNode,
utils::clonecell::CloneCell,
xwayland::XWaylandEvent,
},
std::rc::Rc,
};
pub mod xwindow;
pub struct XSurface {
pub surface: Rc<WlSurface>,
pub xwindow: CloneCell<Option<Rc<Xwindow>>>,
pub tracker: Tracker<Self>,
}
impl SurfaceExt for XSurface {
fn post_commit(self: Rc<Self>) {
if let Some(xwindow) = self.xwindow.get() {
xwindow.map_status_changed();
}
}
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
self.surface.unset_ext();
if let Some(xwindow) = self.xwindow.take() {
xwindow.tl_destroy();
xwindow.data.window.set(None);
xwindow.data.surface_id.set(None);
xwindow
.data
.state
.xwayland
.queue
.push(XWaylandEvent::SurfaceDestroyed(self.surface.id));
}
Ok(())
}
fn extents_changed(&self) {
if let Some(xwindow) = self.xwindow.get() {
xwindow.toplevel_data.pos.set(self.surface.extents.get());
xwindow.tl_extents_changed();
}
}
fn into_xsurface(self: Rc<Self>) -> Option<Rc<XSurface>> {
Some(self)
}
}