1
0
Fork 0
forked from wry/wry

tree: map toplevel identifiers to toplevels

This commit is contained in:
Julian Orth 2024-10-10 12:43:43 +02:00
parent 43bb787d52
commit e6c3c9c1ed
9 changed files with 57 additions and 27 deletions

View file

@ -1227,7 +1227,7 @@ impl UiDragUsecase for TileDragUsecase {
return;
};
let detach = || {
let placeholder = Rc::new(PlaceholderNode::new_empty(&seat.state));
let placeholder = Rc::new_cyclic(|weak| PlaceholderNode::new_empty(&seat.state, weak));
src_parent
.clone()
.cnode_replace_child(src.tl_as_node(), placeholder.clone());

View file

@ -205,18 +205,21 @@ impl Xwindow {
if xsurface.xwindow.is_some() {
return Err(XWindowError::AlreadyAttached);
}
let tld = ToplevelData::new(
&data.state,
data.info.title.borrow_mut().clone().unwrap_or_default(),
Some(surface.client.clone()),
);
tld.pos.set(surface.extents.get());
let slf = Rc::new(Self {
id: data.state.node_ids.next(),
data: data.clone(),
display_link: Default::default(),
toplevel_data: tld,
x: xsurface,
let slf = Rc::new_cyclic(|weak| {
let tld = ToplevelData::new(
&data.state,
data.info.title.borrow_mut().clone().unwrap_or_default(),
Some(surface.client.clone()),
weak,
);
tld.pos.set(surface.extents.get());
Self {
id: data.state.node_ids.next(),
data: data.clone(),
display_link: Default::default(),
toplevel_data: tld,
x: xsurface,
}
});
slf.x.xwindow.set(Some(slf.clone()));
slf.x.surface.set_toplevel(Some(slf.clone()));

View file

@ -347,7 +347,7 @@ impl XdgSurfaceRequestHandler for XdgSurface {
);
return Err(XdgSurfaceError::AlreadyConstructed);
}
let toplevel = Rc::new(XdgToplevel::new(req.id, slf));
let toplevel = Rc::new_cyclic(|weak| XdgToplevel::new(req.id, slf, weak));
track!(self.surface.client, toplevel);
self.surface.client.add_client_obj(&toplevel)?;
self.ext.set(Some(toplevel.clone()));

View file

@ -38,7 +38,7 @@ use {
cell::{Cell, RefCell},
fmt::{Debug, Formatter},
mem,
rc::Rc,
rc::{Rc, Weak},
},
thiserror::Error,
};
@ -115,7 +115,7 @@ impl Debug for XdgToplevel {
}
impl XdgToplevel {
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>) -> Self {
pub fn new(id: XdgToplevelId, surface: &Rc<XdgSurface>, slf: &Weak<Self>) -> Self {
let mut states = AHashSet::new();
states.insert(STATE_TILED_LEFT);
states.insert(STATE_TILED_RIGHT);
@ -141,6 +141,7 @@ impl XdgToplevel {
state,
String::new(),
Some(surface.surface.client.clone()),
slf,
),
drag: Default::default(),
is_mapped: Cell::new(false),