tree: map toplevel identifiers to toplevels
This commit is contained in:
parent
43bb787d52
commit
e6c3c9c1ed
9 changed files with 57 additions and 27 deletions
|
|
@ -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()));
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue