tree: clean up object attachment
This commit is contained in:
parent
ed129c1c3d
commit
fe804b8276
8 changed files with 140 additions and 115 deletions
|
|
@ -379,7 +379,7 @@ impl ToplevelNodeBase for Xwindow {
|
||||||
Some(self.x.surface.clone())
|
Some(self.x.surface.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
self.x.surface.set_output(&ws.output.get());
|
self.x.surface.set_output(&ws.output.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ impl ToplevelNodeBase for XdgToplevel {
|
||||||
Some(self.xdg.surface.clone())
|
Some(self.xdg.surface.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
self.xdg.set_workspace(ws);
|
self.xdg.set_workspace(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -520,7 +520,6 @@ impl State {
|
||||||
mut height: i32,
|
mut height: i32,
|
||||||
workspace: &Rc<WorkspaceNode>,
|
workspace: &Rc<WorkspaceNode>,
|
||||||
) {
|
) {
|
||||||
node.clone().tl_set_workspace(workspace);
|
|
||||||
width += 2 * self.theme.sizes.border_width.get();
|
width += 2 * self.theme.sizes.border_width.get();
|
||||||
height += 2 * self.theme.sizes.border_width.get() + self.theme.sizes.title_height.get() + 1;
|
height += 2 * self.theme.sizes.border_width.get() + self.theme.sizes.title_height.get() + 1;
|
||||||
let output = workspace.output.get();
|
let output = workspace.output.get();
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,6 @@ impl ContainerNode {
|
||||||
child: Rc<dyn ToplevelNode>,
|
child: Rc<dyn ToplevelNode>,
|
||||||
split: ContainerSplit,
|
split: ContainerSplit,
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
child.clone().tl_set_workspace(workspace);
|
|
||||||
let children = LinkedList::new();
|
let children = LinkedList::new();
|
||||||
let child_node = children.add_last(ContainerChild {
|
let child_node = children.add_last(ContainerChild {
|
||||||
node: child.clone(),
|
node: child.clone(),
|
||||||
|
|
@ -217,7 +216,7 @@ impl ContainerNode {
|
||||||
attention_requests: Default::default(),
|
attention_requests: Default::default(),
|
||||||
});
|
});
|
||||||
child.tl_set_parent(slf.clone());
|
child.tl_set_parent(slf.clone());
|
||||||
slf.apply_child_flags(&child_node_ref);
|
slf.pull_child_properties(&child_node_ref);
|
||||||
slf
|
slf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,9 +300,8 @@ impl ContainerNode {
|
||||||
links.insert(new.node_id(), link);
|
links.insert(new.node_id(), link);
|
||||||
r
|
r
|
||||||
};
|
};
|
||||||
self.apply_child_flags(&new_ref);
|
|
||||||
new.clone().tl_set_workspace(&self.workspace.get());
|
|
||||||
new.tl_set_parent(self.clone());
|
new.tl_set_parent(self.clone());
|
||||||
|
self.pull_child_properties(&new_ref);
|
||||||
new.tl_set_visible(self.toplevel_data.visible.get());
|
new.tl_set_visible(self.toplevel_data.visible.get());
|
||||||
let num_children = self.num_children.fetch_add(1) + 1;
|
let num_children = self.num_children.fetch_add(1) + 1;
|
||||||
self.update_content_size();
|
self.update_content_size();
|
||||||
|
|
@ -605,7 +603,7 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_title(self: &Rc<Self>) {
|
fn update_title(&self) {
|
||||||
let mut title = self.toplevel_data.title.borrow_mut();
|
let mut title = self.toplevel_data.title.borrow_mut();
|
||||||
title.clear();
|
title.clear();
|
||||||
let split = match (self.mono_child.get().is_some(), self.split.get()) {
|
let split = match (self.mono_child.get().is_some(), self.split.get()) {
|
||||||
|
|
@ -951,16 +949,70 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_child_flags(&self, child: &ContainerChild) {
|
fn update_child_title(self: &Rc<Self>, child: &ContainerChild, title: &str) {
|
||||||
let data = child.node.tl_data();
|
{
|
||||||
let attention_requested = data.wants_attention.get();
|
let mut ct = child.title.borrow_mut();
|
||||||
child.attention_requested.set(attention_requested);
|
if ct.deref() == title {
|
||||||
if attention_requested {
|
return;
|
||||||
self.mod_attention_requests(true);
|
}
|
||||||
|
ct.clear();
|
||||||
|
ct.push_str(title);
|
||||||
|
}
|
||||||
|
self.update_title();
|
||||||
|
// log::info!("node_child_title_changed");
|
||||||
|
self.schedule_compute_render_data();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_child_active(
|
||||||
|
self: &Rc<Self>,
|
||||||
|
node: &NodeRef<ContainerChild>,
|
||||||
|
active: bool,
|
||||||
|
depth: u32,
|
||||||
|
) {
|
||||||
|
if depth == 1 {
|
||||||
|
node.active.set(active);
|
||||||
|
}
|
||||||
|
if active {
|
||||||
|
node.focus_history
|
||||||
|
.set(Some(self.focus_history.add_last(node.clone())));
|
||||||
|
}
|
||||||
|
// log::info!("node_child_active_changed");
|
||||||
|
self.schedule_compute_render_data();
|
||||||
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
|
parent.node_child_active_changed(self.deref(), active, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discard_child_flags(&self, child: &ContainerChild) {
|
fn update_child_size(&self, node: &NodeRef<ContainerChild>, width: i32, height: i32) {
|
||||||
|
let rect = Rect::new(0, 0, width, height).unwrap();
|
||||||
|
node.content.set(rect);
|
||||||
|
node.position_content();
|
||||||
|
if let Some(mono) = self.mono_child.get() {
|
||||||
|
if mono.node.node_id() == node.node.node_id() {
|
||||||
|
let body = self.mono_body.get();
|
||||||
|
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pull_child_properties(self: &Rc<Self>, child: &NodeRef<ContainerChild>) {
|
||||||
|
let data = child.node.tl_data();
|
||||||
|
{
|
||||||
|
let attention_requested = data.wants_attention.get();
|
||||||
|
child.attention_requested.set(attention_requested);
|
||||||
|
if attention_requested {
|
||||||
|
self.mod_attention_requests(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.update_child_title(child, &data.title.borrow());
|
||||||
|
self.update_child_active(child, data.active(), 1);
|
||||||
|
{
|
||||||
|
let pos = data.pos.get();
|
||||||
|
self.update_child_size(child, pos.width(), pos.height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn discard_child_properties(&self, child: &ContainerChild) {
|
||||||
if child.attention_requested.get() {
|
if child.attention_requested.get() {
|
||||||
self.mod_attention_requests(false);
|
self.mod_attention_requests(false);
|
||||||
}
|
}
|
||||||
|
|
@ -1042,21 +1094,9 @@ impl Node for ContainerNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
|
fn node_child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
|
||||||
let child = match self.child_nodes.borrow().get(&child.node_id()) {
|
if let Some(child) = self.child_nodes.borrow().get(&child.node_id()) {
|
||||||
Some(cn) => cn.to_ref(),
|
self.update_child_title(child, title);
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
{
|
|
||||||
let mut ct = child.title.borrow_mut();
|
|
||||||
if ct.deref() == title {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ct.clear();
|
|
||||||
ct.push_str(title);
|
|
||||||
}
|
}
|
||||||
self.update_title();
|
|
||||||
// log::info!("node_child_title_changed");
|
|
||||||
self.schedule_compute_render_data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||||
|
|
@ -1115,34 +1155,13 @@ impl Node for ContainerNode {
|
||||||
fn node_child_size_changed(&self, child: &dyn Node, width: i32, height: i32) {
|
fn node_child_size_changed(&self, child: &dyn Node, width: i32, height: i32) {
|
||||||
let cn = self.child_nodes.borrow();
|
let cn = self.child_nodes.borrow();
|
||||||
if let Some(node) = cn.get(&child.node_id()) {
|
if let Some(node) = cn.get(&child.node_id()) {
|
||||||
let rect = Rect::new(0, 0, width, height).unwrap();
|
self.update_child_size(node, width, height);
|
||||||
node.content.set(rect);
|
|
||||||
node.position_content();
|
|
||||||
if let Some(mono) = self.mono_child.get() {
|
|
||||||
if mono.node.node_id() == node.node.node_id() {
|
|
||||||
let body = self.mono_body.get();
|
|
||||||
self.mono_content.set(rect.at_point(body.x1(), body.y1()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool, depth: u32) {
|
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool, depth: u32) {
|
||||||
let node = match self.child_nodes.borrow().get(&child.node_id()) {
|
if let Some(l) = self.child_nodes.borrow().get(&child.node_id()) {
|
||||||
Some(l) => l.to_ref(),
|
self.update_child_active(l, active, depth);
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
if depth == 1 {
|
|
||||||
node.active.set(active);
|
|
||||||
}
|
|
||||||
if active {
|
|
||||||
node.focus_history
|
|
||||||
.set(Some(self.focus_history.add_last(node.clone())));
|
|
||||||
}
|
|
||||||
// log::info!("node_child_active_changed");
|
|
||||||
self.schedule_compute_render_data();
|
|
||||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
|
||||||
parent.node_child_active_changed(self.deref(), active, depth + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1314,7 +1333,7 @@ impl ContainingNode for ContainerNode {
|
||||||
None => (false, false),
|
None => (false, false),
|
||||||
Some(mc) => (true, mc.node.node_id() == old.node_id()),
|
Some(mc) => (true, mc.node.node_id() == old.node_id()),
|
||||||
};
|
};
|
||||||
self.discard_child_flags(&node);
|
self.discard_child_properties(&node);
|
||||||
let link = node.append(ContainerChild {
|
let link = node.append(ContainerChild {
|
||||||
node: new.clone(),
|
node: new.clone(),
|
||||||
active: Cell::new(false),
|
active: Cell::new(false),
|
||||||
|
|
@ -1327,11 +1346,10 @@ impl ContainingNode for ContainerNode {
|
||||||
focus_history: Cell::new(None),
|
focus_history: Cell::new(None),
|
||||||
attention_requested: Cell::new(false),
|
attention_requested: Cell::new(false),
|
||||||
});
|
});
|
||||||
self.apply_child_flags(&link);
|
|
||||||
if let Some(fh) = node.focus_history.take() {
|
if let Some(fh) = node.focus_history.take() {
|
||||||
link.focus_history.set(Some(fh.append(link.to_ref())));
|
link.focus_history.set(Some(fh.append(link.to_ref())));
|
||||||
}
|
}
|
||||||
new.tl_set_visible(node.node.node_visible());
|
let visible = node.node.node_visible();
|
||||||
drop(node);
|
drop(node);
|
||||||
let mut body = None;
|
let mut body = None;
|
||||||
if was_mc {
|
if was_mc {
|
||||||
|
|
@ -1340,9 +1358,11 @@ impl ContainingNode for ContainerNode {
|
||||||
} else if !have_mc {
|
} else if !have_mc {
|
||||||
body = Some(link.body.get());
|
body = Some(link.body.get());
|
||||||
};
|
};
|
||||||
|
let link_ref = link.to_ref();
|
||||||
self.child_nodes.borrow_mut().insert(new.node_id(), link);
|
self.child_nodes.borrow_mut().insert(new.node_id(), link);
|
||||||
new.tl_set_parent(self.clone());
|
new.tl_set_parent(self.clone());
|
||||||
new.clone().tl_set_workspace(&self.workspace.get());
|
self.pull_child_properties(&link_ref);
|
||||||
|
new.tl_set_visible(visible);
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
let body = body.move_(self.abs_x1.get(), self.abs_y1.get());
|
||||||
new.clone().tl_change_extents(&body);
|
new.clone().tl_change_extents(&body);
|
||||||
|
|
@ -1355,7 +1375,7 @@ impl ContainingNode for ContainerNode {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
node.focus_history.set(None);
|
node.focus_history.set(None);
|
||||||
self.discard_child_flags(&node);
|
self.discard_child_properties(&node);
|
||||||
if let Some(mono) = self.mono_child.get() {
|
if let Some(mono) = self.mono_child.get() {
|
||||||
if mono.node.node_id() == child.node_id() {
|
if mono.node.node_id() == child.node_id() {
|
||||||
let mut new = self.focus_history.last().map(|n| n.deref().clone());
|
let mut new = self.focus_history.last().map(|n| n.deref().clone());
|
||||||
|
|
@ -1419,6 +1439,10 @@ impl ContainingNode for ContainerNode {
|
||||||
self.mod_attention_requests(set);
|
self.mod_attention_requests(set);
|
||||||
self.schedule_compute_render_data();
|
self.schedule_compute_render_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode> {
|
||||||
|
self.workspace.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelNodeBase for ContainerNode {
|
impl ToplevelNodeBase for ContainerNode {
|
||||||
|
|
@ -1434,7 +1458,7 @@ impl ToplevelNodeBase for ContainerNode {
|
||||||
.map(|tl| tl.tl_into_node())
|
.map(|tl| tl.tl_into_node())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
for child in self.children.iter() {
|
for child in self.children.iter() {
|
||||||
child.node.clone().tl_set_workspace(ws);
|
child.node.clone().tl_set_workspace(ws);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use {
|
use {
|
||||||
crate::tree::{Node, ToplevelNode},
|
crate::tree::{Node, ToplevelNode, WorkspaceNode},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -15,4 +15,5 @@ pub trait ContainingNode: Node {
|
||||||
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, preserve_focus: bool);
|
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, preserve_focus: bool);
|
||||||
fn cnode_accepts_child(&self, node: &dyn Node) -> bool;
|
fn cnode_accepts_child(&self, node: &dyn Node) -> bool;
|
||||||
fn cnode_child_attention_request_changed(self: Rc<Self>, child: &dyn Node, set: bool);
|
fn cnode_child_attention_request_changed(self: Rc<Self>, child: &dyn Node, set: bool);
|
||||||
|
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,14 +115,13 @@ impl FloatNode {
|
||||||
seats: Default::default(),
|
seats: Default::default(),
|
||||||
attention_requested: Cell::new(false),
|
attention_requested: Cell::new(false),
|
||||||
});
|
});
|
||||||
floater.apply_child_flags();
|
floater.pull_child_properties();
|
||||||
floater
|
floater
|
||||||
.display_link
|
.display_link
|
||||||
.set(Some(state.root.stacked.add_last(floater.clone())));
|
.set(Some(state.root.stacked.add_last(floater.clone())));
|
||||||
floater
|
floater
|
||||||
.workspace_link
|
.workspace_link
|
||||||
.set(Some(ws.stacked.add_last(floater.clone())));
|
.set(Some(ws.stacked.add_last(floater.clone())));
|
||||||
child.clone().tl_set_workspace(ws);
|
|
||||||
child.tl_set_parent(floater.clone());
|
child.tl_set_parent(floater.clone());
|
||||||
child.tl_set_visible(floater.visible.get());
|
child.tl_set_visible(floater.visible.get());
|
||||||
floater.schedule_layout();
|
floater.schedule_layout();
|
||||||
|
|
@ -349,7 +348,22 @@ impl FloatNode {
|
||||||
self.stacked_set_visible(ws.stacked_visible());
|
self.stacked_set_visible(ws.stacked_visible());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_child_flags(&self) {
|
fn update_child_title(self: &Rc<Self>, title: &str) {
|
||||||
|
let mut t = self.title.borrow_mut();
|
||||||
|
if t.deref() != title {
|
||||||
|
t.clear();
|
||||||
|
t.push_str(title);
|
||||||
|
self.schedule_render_titles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_child_active(self: &Rc<Self>, active: bool) {
|
||||||
|
if self.active.replace(active) != active {
|
||||||
|
self.schedule_render_titles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pull_child_properties(self: &Rc<Self>) {
|
||||||
let child = match self.child.get() {
|
let child = match self.child.get() {
|
||||||
None => return,
|
None => return,
|
||||||
Some(c) => c,
|
Some(c) => c,
|
||||||
|
|
@ -360,11 +374,13 @@ impl FloatNode {
|
||||||
if activation_requested {
|
if activation_requested {
|
||||||
self.workspace
|
self.workspace
|
||||||
.get()
|
.get()
|
||||||
.cnode_child_attention_request_changed(self, true);
|
.cnode_child_attention_request_changed(&**self, true);
|
||||||
}
|
}
|
||||||
|
self.update_child_title(&data.title.borrow());
|
||||||
|
self.update_child_active(data.active());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discard_child_flags(&self) {
|
fn discard_child_properties(&self) {
|
||||||
if self.attention_requested.get() {
|
if self.attention_requested.get() {
|
||||||
self.workspace
|
self.workspace
|
||||||
.get()
|
.get()
|
||||||
|
|
@ -407,12 +423,7 @@ impl Node for FloatNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_child_title_changed(self: Rc<Self>, _child: &dyn Node, title: &str) {
|
fn node_child_title_changed(self: Rc<Self>, _child: &dyn Node, title: &str) {
|
||||||
let mut t = self.title.borrow_mut();
|
self.update_child_title(title);
|
||||||
if t.deref() != title {
|
|
||||||
t.clear();
|
|
||||||
t.push_str(title);
|
|
||||||
self.schedule_render_titles();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||||
|
|
@ -441,9 +452,7 @@ impl Node for FloatNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_child_active_changed(self: Rc<Self>, _child: &dyn Node, active: bool, _depth: u32) {
|
fn node_child_active_changed(self: Rc<Self>, _child: &dyn Node, active: bool, _depth: u32) {
|
||||||
if self.active.replace(active) != active {
|
self.update_child_active(active);
|
||||||
self.schedule_render_titles();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32, _bounds: Option<&Rect>) {
|
||||||
|
|
@ -546,16 +555,16 @@ impl ContainingNode for FloatNode {
|
||||||
containing_node_impl!();
|
containing_node_impl!();
|
||||||
|
|
||||||
fn cnode_replace_child(self: Rc<Self>, _old: &dyn Node, new: Rc<dyn ToplevelNode>) {
|
fn cnode_replace_child(self: Rc<Self>, _old: &dyn Node, new: Rc<dyn ToplevelNode>) {
|
||||||
self.discard_child_flags();
|
self.discard_child_properties();
|
||||||
self.child.set(Some(new.clone()));
|
self.child.set(Some(new.clone()));
|
||||||
self.apply_child_flags();
|
|
||||||
new.tl_set_parent(self.clone());
|
new.tl_set_parent(self.clone());
|
||||||
new.clone().tl_set_workspace(&self.workspace.get());
|
self.pull_child_properties();
|
||||||
|
new.tl_set_visible(self.visible.get());
|
||||||
self.schedule_layout();
|
self.schedule_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cnode_remove_child2(self: Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
fn cnode_remove_child2(self: Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
||||||
self.discard_child_flags();
|
self.discard_child_properties();
|
||||||
self.child.set(None);
|
self.child.set(None);
|
||||||
self.display_link.set(None);
|
self.display_link.set(None);
|
||||||
self.workspace_link.set(None);
|
self.workspace_link.set(None);
|
||||||
|
|
@ -572,6 +581,10 @@ impl ContainingNode for FloatNode {
|
||||||
.cnode_child_attention_request_changed(&*self, set);
|
.cnode_child_attention_request_changed(&*self, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode> {
|
||||||
|
self.workspace.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StackedNode for FloatNode {
|
impl StackedNode for FloatNode {
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,8 @@ pub trait ToplevelNode: ToplevelNodeBase {
|
||||||
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool);
|
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool);
|
||||||
fn tl_title_changed(&self);
|
fn tl_title_changed(&self);
|
||||||
fn tl_set_parent(&self, parent: Rc<dyn ContainingNode>);
|
fn tl_set_parent(&self, parent: Rc<dyn ContainingNode>);
|
||||||
fn tl_active_changed(&self);
|
|
||||||
fn tl_extents_changed(&self);
|
fn tl_extents_changed(&self);
|
||||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>);
|
fn tl_set_workspace(&self, ws: &Rc<WorkspaceNode>);
|
||||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect);
|
fn tl_change_extents(self: Rc<Self>, rect: &Rect);
|
||||||
fn tl_set_visible(&self, visible: bool);
|
fn tl_set_visible(&self, visible: bool);
|
||||||
fn tl_destroy(&self);
|
fn tl_destroy(&self);
|
||||||
|
|
@ -103,36 +102,19 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
data.parent.set(Some(parent.clone()));
|
data.parent.set(Some(parent.clone()));
|
||||||
data.is_floating.set(parent.node_is_float());
|
data.is_floating.set(parent.node_is_float());
|
||||||
self.tl_extents_changed();
|
self.tl_set_workspace(&parent.cnode_workspace());
|
||||||
self.tl_title_changed();
|
|
||||||
self.tl_active_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_active_changed(&self) {
|
|
||||||
let data = self.tl_data();
|
|
||||||
let parent = match data.parent.get() {
|
|
||||||
Some(p) => p,
|
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
let node = self.tl_as_node();
|
|
||||||
if data.active.get() || data.active_surfaces.active() {
|
|
||||||
parent.clone().node_child_active_changed(node, true, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_extents_changed(&self) {
|
fn tl_extents_changed(&self) {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
let parent = match data.parent.get() {
|
if let Some(parent) = data.parent.get() {
|
||||||
Some(p) => p,
|
let pos = data.pos.get();
|
||||||
_ => return,
|
parent.node_child_size_changed(self, pos.width(), pos.height());
|
||||||
};
|
data.state.tree_changed();
|
||||||
let node = self.tl_as_node();
|
}
|
||||||
let pos = data.pos.get();
|
|
||||||
parent.node_child_size_changed(node, pos.width(), pos.height());
|
|
||||||
data.state.tree_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
fn tl_set_workspace(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
data.workspace.set(Some(ws.clone()));
|
data.workspace.set(Some(ws.clone()));
|
||||||
self.tl_set_workspace_ext(ws);
|
self.tl_set_workspace_ext(ws);
|
||||||
|
|
@ -184,7 +166,7 @@ pub trait ToplevelNodeBase: Node {
|
||||||
.or_else(|| self.tl_default_focus_child())
|
.or_else(|| self.tl_default_focus_child())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
let _ = ws;
|
let _ = ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,6 +241,10 @@ impl ToplevelData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn active(&self) -> bool {
|
||||||
|
self.active_surfaces.active() || self.active.get()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn float_size(&self, ws: &WorkspaceNode) -> (i32, i32) {
|
pub fn float_size(&self, ws: &WorkspaceNode) -> (i32, i32) {
|
||||||
let output = ws.output.get().global.pos.get();
|
let output = ws.output.get().global.pos.get();
|
||||||
let mut width = self.float_width.get();
|
let mut width = self.float_width.get();
|
||||||
|
|
@ -401,7 +387,6 @@ impl ToplevelData {
|
||||||
self.is_fullscreen.set(true);
|
self.is_fullscreen.set(true);
|
||||||
node.tl_set_parent(ws.clone());
|
node.tl_set_parent(ws.clone());
|
||||||
ws.set_fullscreen_node(&node);
|
ws.set_fullscreen_node(&node);
|
||||||
node.clone().tl_set_workspace(ws);
|
|
||||||
node.clone()
|
node.clone()
|
||||||
.tl_change_extents(&ws.output.get().global.pos.get());
|
.tl_change_extents(&ws.output.get().global.pos.get());
|
||||||
for seat in kb_foci {
|
for seat in kb_foci {
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,11 @@ impl WorkspaceNode {
|
||||||
|
|
||||||
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
|
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
|
||||||
if let Some(prev) = self.container.get() {
|
if let Some(prev) = self.container.get() {
|
||||||
self.discard_child_flags(&*prev);
|
self.discard_child_properties(&*prev);
|
||||||
}
|
}
|
||||||
self.apply_child_flags(&**container);
|
self.pull_child_properties(&**container);
|
||||||
let pos = self.position.get();
|
let pos = self.position.get();
|
||||||
container.clone().tl_change_extents(&pos);
|
container.clone().tl_change_extents(&pos);
|
||||||
container.clone().tl_set_workspace(self);
|
|
||||||
container.tl_set_parent(self.clone());
|
container.tl_set_parent(self.clone());
|
||||||
container.tl_set_visible(self.stacked_visible());
|
container.tl_set_visible(self.stacked_visible());
|
||||||
self.container.set(Some(container.clone()));
|
self.container.set(Some(container.clone()));
|
||||||
|
|
@ -136,9 +135,9 @@ impl WorkspaceNode {
|
||||||
let mut plane_was_visible = visible;
|
let mut plane_was_visible = visible;
|
||||||
if let Some(prev) = self.fullscreen.set(Some(node.clone())) {
|
if let Some(prev) = self.fullscreen.set(Some(node.clone())) {
|
||||||
plane_was_visible = false;
|
plane_was_visible = false;
|
||||||
self.discard_child_flags(&*prev);
|
self.discard_child_properties(&*prev);
|
||||||
}
|
}
|
||||||
self.apply_child_flags(&**node);
|
self.pull_child_properties(&**node);
|
||||||
node.tl_set_visible(visible);
|
node.tl_set_visible(visible);
|
||||||
if plane_was_visible {
|
if plane_was_visible {
|
||||||
self.plane_set_visible(false);
|
self.plane_set_visible(false);
|
||||||
|
|
@ -152,7 +151,7 @@ impl WorkspaceNode {
|
||||||
|
|
||||||
pub fn remove_fullscreen_node(&self) {
|
pub fn remove_fullscreen_node(&self) {
|
||||||
if let Some(node) = self.fullscreen.take() {
|
if let Some(node) = self.fullscreen.take() {
|
||||||
self.discard_child_flags(&*node);
|
self.discard_child_properties(&*node);
|
||||||
if self.visible.get() {
|
if self.visible.get() {
|
||||||
self.plane_set_visible(true);
|
self.plane_set_visible(true);
|
||||||
}
|
}
|
||||||
|
|
@ -164,13 +163,13 @@ impl WorkspaceNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_child_flags(&self, child: &dyn ToplevelNode) {
|
fn pull_child_properties(&self, child: &dyn ToplevelNode) {
|
||||||
if child.tl_data().wants_attention.get() {
|
if child.tl_data().wants_attention.get() {
|
||||||
self.mod_attention_requested(true);
|
self.mod_attention_requested(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discard_child_flags(&self, child: &dyn ToplevelNode) {
|
fn discard_child_properties(&self, child: &dyn ToplevelNode) {
|
||||||
if child.tl_data().wants_attention.get() {
|
if child.tl_data().wants_attention.get() {
|
||||||
self.mod_attention_requested(false);
|
self.mod_attention_requested(false);
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +278,7 @@ impl ContainingNode for WorkspaceNode {
|
||||||
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
|
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
|
||||||
if let Some(container) = self.container.get() {
|
if let Some(container) = self.container.get() {
|
||||||
if container.node_id() == child.node_id() {
|
if container.node_id() == child.node_id() {
|
||||||
self.discard_child_flags(&*container);
|
self.discard_child_properties(&*container);
|
||||||
self.container.set(None);
|
self.container.set(None);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -300,4 +299,8 @@ impl ContainingNode for WorkspaceNode {
|
||||||
fn cnode_child_attention_request_changed(self: Rc<Self>, _node: &dyn Node, set: bool) {
|
fn cnode_child_attention_request_changed(self: Rc<Self>, _node: &dyn Node, set: bool) {
|
||||||
self.mod_attention_requested(set);
|
self.mod_attention_requested(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode> {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue