tree: map toplevel identifiers to toplevels
This commit is contained in:
parent
43bb787d52
commit
e6c3c9c1ed
9 changed files with 57 additions and 27 deletions
|
|
@ -213,7 +213,7 @@ impl ContainerNode {
|
|||
let child_node_ref = child_node.clone();
|
||||
let mut child_nodes = AHashMap::new();
|
||||
child_nodes.insert(child.node_id(), child_node);
|
||||
let slf = Rc::new(Self {
|
||||
let slf = Rc::new_cyclic(|weak| Self {
|
||||
id: state.node_ids.next(),
|
||||
split: Cell::new(split),
|
||||
mono_child: CloneCell::new(None),
|
||||
|
|
@ -238,7 +238,7 @@ impl ContainerNode {
|
|||
state: state.clone(),
|
||||
render_data: Default::default(),
|
||||
scroller: Default::default(),
|
||||
toplevel_data: ToplevelData::new(state, Default::default(), None),
|
||||
toplevel_data: ToplevelData::new(state, Default::default(), None, weak),
|
||||
attention_requests: Default::default(),
|
||||
});
|
||||
child.tl_set_parent(slf.clone());
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use {
|
|||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
rc::{Rc, Weak},
|
||||
sync::Arc,
|
||||
},
|
||||
};
|
||||
|
|
@ -48,13 +48,14 @@ pub async fn placeholder_render_textures(state: Rc<State>) {
|
|||
}
|
||||
|
||||
impl PlaceholderNode {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn ToplevelNode>) -> Self {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn ToplevelNode>, slf: &Weak<Self>) -> Self {
|
||||
Self {
|
||||
id: state.node_ids.next(),
|
||||
toplevel: ToplevelData::new(
|
||||
state,
|
||||
node.tl_data().title.borrow().clone(),
|
||||
node.node_client(),
|
||||
slf,
|
||||
),
|
||||
destroyed: Default::default(),
|
||||
update_textures_scheduled: Cell::new(false),
|
||||
|
|
@ -63,10 +64,10 @@ impl PlaceholderNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_empty(state: &Rc<State>) -> Self {
|
||||
pub fn new_empty(state: &Rc<State>, slf: &Weak<Self>) -> Self {
|
||||
Self {
|
||||
id: state.node_ids.next(),
|
||||
toplevel: ToplevelData::new(state, String::new(), None),
|
||||
toplevel: ToplevelData::new(state, String::new(), None, slf),
|
||||
destroyed: Default::default(),
|
||||
update_textures_scheduled: Default::default(),
|
||||
state: state.clone(),
|
||||
|
|
|
|||
|
|
@ -282,10 +282,18 @@ pub struct ToplevelData {
|
|||
pub jay_screencasts: CopyHashMap<(ClientId, JayScreencastId), Rc<JayScreencast>>,
|
||||
pub ext_copy_sessions:
|
||||
CopyHashMap<(ClientId, ExtImageCopyCaptureSessionV1Id), Rc<ExtImageCopyCaptureSessionV1>>,
|
||||
pub slf: Weak<dyn ToplevelNode>,
|
||||
}
|
||||
|
||||
impl ToplevelData {
|
||||
pub fn new(state: &Rc<State>, title: String, client: Option<Rc<Client>>) -> Self {
|
||||
pub fn new<T: ToplevelNode>(
|
||||
state: &Rc<State>,
|
||||
title: String,
|
||||
client: Option<Rc<Client>>,
|
||||
slf: &Weak<T>,
|
||||
) -> Self {
|
||||
let id = toplevel_identifier();
|
||||
state.toplevels.set(id, slf.clone());
|
||||
Self {
|
||||
self_active: Cell::new(false),
|
||||
client,
|
||||
|
|
@ -307,12 +315,13 @@ impl ToplevelData {
|
|||
wants_attention: Cell::new(false),
|
||||
requested_attention: Cell::new(false),
|
||||
app_id: Default::default(),
|
||||
identifier: Cell::new(toplevel_identifier()),
|
||||
identifier: Cell::new(id),
|
||||
handles: Default::default(),
|
||||
render_highlight: Default::default(),
|
||||
jay_toplevels: Default::default(),
|
||||
jay_screencasts: Default::default(),
|
||||
ext_copy_sessions: Default::default(),
|
||||
slf: slf.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +368,12 @@ impl ToplevelData {
|
|||
for screencast in self.ext_copy_sessions.lock().drain_values() {
|
||||
screencast.stop();
|
||||
}
|
||||
self.identifier.set(toplevel_identifier());
|
||||
{
|
||||
let id = toplevel_identifier();
|
||||
let prev = self.identifier.replace(id);
|
||||
self.state.toplevels.remove(&prev);
|
||||
self.state.toplevels.set(id, self.slf.clone());
|
||||
}
|
||||
{
|
||||
let mut handles = self.handles.lock();
|
||||
for handle in handles.drain_values() {
|
||||
|
|
@ -476,7 +490,8 @@ impl ToplevelData {
|
|||
log::warn!("Cannot fullscreen root container in a workspace");
|
||||
return;
|
||||
}
|
||||
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
||||
let placeholder =
|
||||
Rc::new_cyclic(|weak| PlaceholderNode::new_for(state, node.clone(), weak));
|
||||
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
|
||||
let mut kb_foci = Default::default();
|
||||
if ws.visible.get() {
|
||||
|
|
@ -599,6 +614,12 @@ impl ToplevelData {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for ToplevelData {
|
||||
fn drop(&mut self) {
|
||||
self.state.toplevels.remove(&self.identifier.get());
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TileDragDestination {
|
||||
pub highlight: Rect,
|
||||
pub ty: TddType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue