Merge pull request #102 from mahkoh/jorth/fix-tl-change-extents
tree: various fixes
This commit is contained in:
commit
c1421fca32
16 changed files with 273 additions and 235 deletions
|
|
@ -574,7 +574,7 @@ impl WlSeatGlobal {
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
if let Some(pn) = pn.node_into_containing_node() {
|
if let Some(pn) = pn.node_into_containing_node() {
|
||||||
let cn = ContainerNode::new(&self.state, &ws, pn.clone(), tl.clone(), axis);
|
let cn = ContainerNode::new(&self.state, &ws, tl.clone(), axis);
|
||||||
pn.cnode_replace_child(tl.tl_as_node(), cn);
|
pn.cnode_replace_child(tl.tl_as_node(), cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -582,7 +582,10 @@ impl WlSeatGlobal {
|
||||||
pub fn focus_parent(self: &Rc<Self>) {
|
pub fn focus_parent(self: &Rc<Self>) {
|
||||||
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
if let Some(tl) = self.keyboard_node.get().node_toplevel() {
|
||||||
if let Some(parent) = tl.tl_data().parent.get() {
|
if let Some(parent) = tl.tl_data().parent.get() {
|
||||||
self.focus_node(parent.cnode_into_node());
|
if let Some(tl) = parent.node_toplevel() {
|
||||||
|
self.focus_node(tl.tl_into_node());
|
||||||
|
self.state.damage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use {
|
||||||
state::State,
|
state::State,
|
||||||
tree::{
|
tree::{
|
||||||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode,
|
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, StackedNode,
|
||||||
ToplevelData, ToplevelNode, WorkspaceNode,
|
ToplevelData, ToplevelNode, ToplevelNodeBase, WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
|
utils::{clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode},
|
||||||
wire::WlSurfaceId,
|
wire::WlSurfaceId,
|
||||||
|
|
@ -357,9 +357,7 @@ impl Node for Xwindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelNode for Xwindow {
|
impl ToplevelNodeBase for Xwindow {
|
||||||
tl_node_impl!();
|
|
||||||
|
|
||||||
fn tl_data(&self) -> &ToplevelData {
|
fn tl_data(&self) -> &ToplevelData {
|
||||||
&self.toplevel_data
|
&self.toplevel_data
|
||||||
}
|
}
|
||||||
|
|
@ -381,7 +379,7 @@ impl ToplevelNode 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,17 +408,19 @@ impl ToplevelNode for Xwindow {
|
||||||
.push(XWaylandEvent::Close(self.data.clone()));
|
.push(XWaylandEvent::Close(self.data.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_visible(&self, visible: bool) {
|
fn tl_set_visible_impl(&self, visible: bool) {
|
||||||
self.x.surface.set_visible(visible);
|
self.x.surface.set_visible(visible);
|
||||||
self.toplevel_data.set_visible(self, visible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_destroy(&self) {
|
fn tl_destroy_impl(&self) {
|
||||||
self.toplevel_data.destroy_node(self);
|
|
||||||
self.display_link.borrow_mut().take();
|
self.display_link.borrow_mut().take();
|
||||||
self.x.surface.destroy_node();
|
self.x.surface.destroy_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
||||||
Some(self.x.surface.clone())
|
Some(self.x.surface.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use {
|
||||||
state::State,
|
state::State,
|
||||||
tree::{
|
tree::{
|
||||||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
|
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
|
||||||
ToplevelNode, ToplevelNodeId, WorkspaceNode,
|
ToplevelNode, ToplevelNodeBase, ToplevelNodeId, WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
buffd::{MsgParser, MsgParserError},
|
buffd::{MsgParser, MsgParserError},
|
||||||
|
|
@ -453,9 +453,7 @@ impl Node for XdgToplevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelNode for XdgToplevel {
|
impl ToplevelNodeBase for XdgToplevel {
|
||||||
tl_node_impl!();
|
|
||||||
|
|
||||||
fn tl_data(&self) -> &ToplevelData {
|
fn tl_data(&self) -> &ToplevelData {
|
||||||
&self.toplevel_data
|
&self.toplevel_data
|
||||||
}
|
}
|
||||||
|
|
@ -479,7 +477,7 @@ impl ToplevelNode 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -499,13 +497,12 @@ impl ToplevelNode for XdgToplevel {
|
||||||
self.send_close();
|
self.send_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_visible(&self, visible: bool) {
|
fn tl_set_visible_impl(&self, visible: bool) {
|
||||||
// log::info!("set_visible {}", visible);
|
// log::info!("set_visible {}", visible);
|
||||||
// if !visible {
|
// if !visible {
|
||||||
// log::info!("\n{:?}", Backtrace::new());
|
// log::info!("\n{:?}", Backtrace::new());
|
||||||
// }
|
// }
|
||||||
self.xdg.set_visible(visible);
|
self.xdg.set_visible(visible);
|
||||||
self.toplevel_data.set_visible(self, visible);
|
|
||||||
if self.xdg.base.version >= SUSPENDED_SINCE {
|
if self.xdg.base.version >= SUSPENDED_SINCE {
|
||||||
if visible {
|
if visible {
|
||||||
self.states.borrow_mut().remove(&STATE_SUSPENDED);
|
self.states.borrow_mut().remove(&STATE_SUSPENDED);
|
||||||
|
|
@ -516,8 +513,7 @@ impl ToplevelNode for XdgToplevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_destroy(&self) {
|
fn tl_destroy_impl(&self) {
|
||||||
self.toplevel_data.destroy_node(self);
|
|
||||||
self.xdg.destroy_node();
|
self.xdg.destroy_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -544,6 +540,10 @@ impl ToplevelNode for XdgToplevel {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
||||||
Some(self.xdg.surface.clone())
|
Some(self.xdg.surface.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use {
|
||||||
test_transport::TestTransport,
|
test_transport::TestTransport,
|
||||||
testrun::ParseFull,
|
testrun::ParseFull,
|
||||||
},
|
},
|
||||||
tree::{ContainerNode, ToplevelNode},
|
tree::{ContainerNode, ToplevelNodeBase},
|
||||||
utils::buffd::MsgParser,
|
utils::buffd::MsgParser,
|
||||||
wire::{xdg_toplevel::*, XdgToplevelId},
|
wire::{xdg_toplevel::*, XdgToplevelId},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
it::{test_error::TestError, testrun::TestRun},
|
it::{test_error::TestError, testrun::TestRun},
|
||||||
tree::ToplevelNode,
|
tree::ToplevelNodeBase,
|
||||||
},
|
},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use {
|
||||||
test_error::{TestErrorExt, TestResult},
|
test_error::{TestErrorExt, TestResult},
|
||||||
testrun::TestRun,
|
testrun::TestRun,
|
||||||
},
|
},
|
||||||
tree::ToplevelNode,
|
tree::ToplevelNodeBase,
|
||||||
},
|
},
|
||||||
jay_config::Axis,
|
jay_config::Axis,
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
it::{test_error::TestResult, testrun::TestRun},
|
it::{test_error::TestResult, testrun::TestRun},
|
||||||
tree::ToplevelNode,
|
tree::ToplevelNodeBase,
|
||||||
},
|
},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -476,22 +476,6 @@ macro_rules! fatal {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! tl_node_impl {
|
|
||||||
() => {
|
|
||||||
fn tl_as_node(&self) -> &dyn Node {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! stacked_node_impl {
|
macro_rules! stacked_node_impl {
|
||||||
() => {
|
() => {
|
||||||
fn stacked_as_node(&self) -> &dyn Node {
|
fn stacked_as_node(&self) -> &dyn Node {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use {
|
||||||
state::State,
|
state::State,
|
||||||
theme::Color,
|
theme::Color,
|
||||||
tree::{
|
tree::{
|
||||||
ContainerNode, DisplayNode, FloatNode, OutputNode, PlaceholderNode, ToplevelNode,
|
ContainerNode, DisplayNode, FloatNode, OutputNode, PlaceholderNode, ToplevelNodeBase,
|
||||||
WorkspaceNode,
|
WorkspaceNode,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ use {
|
||||||
theme::{Color, Theme},
|
theme::{Color, Theme},
|
||||||
tree::{
|
tree::{
|
||||||
ContainerNode, ContainerSplit, Direction, DisplayNode, FloatNode, Node, NodeIds,
|
ContainerNode, ContainerSplit, Direction, DisplayNode, FloatNode, Node, NodeIds,
|
||||||
NodeVisitorBase, OutputNode, PlaceholderNode, ToplevelNode, WorkspaceNode,
|
NodeVisitorBase, OutputNode, PlaceholderNode, ToplevelNode, ToplevelNodeBase,
|
||||||
|
WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
activation_token::ActivationToken, asyncevent::AsyncEvent, clonecell::CloneCell,
|
activation_token::ActivationToken, asyncevent::AsyncEvent, clonecell::CloneCell,
|
||||||
|
|
@ -507,8 +508,7 @@ impl State {
|
||||||
c.append_child(node);
|
c.append_child(node);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let container =
|
let container = ContainerNode::new(self, ws, node, ContainerSplit::Horizontal);
|
||||||
ContainerNode::new(self, ws, ws.clone(), node, ContainerSplit::Horizontal);
|
|
||||||
ws.set_container(&container);
|
ws.set_container(&container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use {
|
||||||
text::{self, TextTexture},
|
text::{self, TextTexture},
|
||||||
tree::{
|
tree::{
|
||||||
walker::NodeVisitor, ContainingNode, Direction, FindTreeResult, FoundNode, Node,
|
walker::NodeVisitor, ContainingNode, Direction, FindTreeResult, FoundNode, Node,
|
||||||
NodeId, ToplevelData, ToplevelNode, WorkspaceNode,
|
NodeId, ToplevelData, ToplevelNode, ToplevelNodeBase, WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
clonecell::CloneCell,
|
clonecell::CloneCell,
|
||||||
|
|
@ -93,7 +93,6 @@ pub struct ContainerRenderData {
|
||||||
|
|
||||||
pub struct ContainerNode {
|
pub struct ContainerNode {
|
||||||
pub id: ContainerNodeId,
|
pub id: ContainerNodeId,
|
||||||
pub parent: CloneCell<Rc<dyn ContainingNode>>,
|
|
||||||
pub split: Cell<ContainerSplit>,
|
pub split: Cell<ContainerSplit>,
|
||||||
pub mono_child: CloneCell<Option<NodeRef<ContainerChild>>>,
|
pub mono_child: CloneCell<Option<NodeRef<ContainerChild>>>,
|
||||||
pub mono_body: Cell<Rect>,
|
pub mono_body: Cell<Rect>,
|
||||||
|
|
@ -170,11 +169,9 @@ impl ContainerNode {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
state: &Rc<State>,
|
state: &Rc<State>,
|
||||||
workspace: &Rc<WorkspaceNode>,
|
workspace: &Rc<WorkspaceNode>,
|
||||||
parent: Rc<dyn ContainingNode>,
|
|
||||||
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(),
|
||||||
|
|
@ -193,7 +190,6 @@ impl ContainerNode {
|
||||||
child_nodes.insert(child.node_id(), child_node);
|
child_nodes.insert(child.node_id(), child_node);
|
||||||
let slf = Rc::new(Self {
|
let slf = Rc::new(Self {
|
||||||
id: state.node_ids.next(),
|
id: state.node_ids.next(),
|
||||||
parent: CloneCell::new(parent.clone()),
|
|
||||||
split: Cell::new(split),
|
split: Cell::new(split),
|
||||||
mono_child: CloneCell::new(None),
|
mono_child: CloneCell::new(None),
|
||||||
mono_body: Cell::new(Default::default()),
|
mono_body: Cell::new(Default::default()),
|
||||||
|
|
@ -219,9 +215,8 @@ impl ContainerNode {
|
||||||
toplevel_data: ToplevelData::new(state, Default::default(), None),
|
toplevel_data: ToplevelData::new(state, Default::default(), None),
|
||||||
attention_requests: Default::default(),
|
attention_requests: Default::default(),
|
||||||
});
|
});
|
||||||
slf.tl_set_parent(parent);
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,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();
|
||||||
|
|
@ -609,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()) {
|
||||||
|
|
@ -821,6 +815,13 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parent_container(&self) -> Option<Rc<ContainerNode>> {
|
||||||
|
self.toplevel_data
|
||||||
|
.parent
|
||||||
|
.get()
|
||||||
|
.and_then(|p| p.node_into_container())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn move_focus_from_child(
|
pub fn move_focus_from_child(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
seat: &Rc<WlSeatGlobal>,
|
seat: &Rc<WlSeatGlobal>,
|
||||||
|
|
@ -843,7 +844,7 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !in_line {
|
if !in_line {
|
||||||
if let Some(c) = self.parent.get().node_into_container() {
|
if let Some(c) = self.parent_container() {
|
||||||
c.move_focus_from_child(seat, self.deref(), direction);
|
c.move_focus_from_child(seat, self.deref(), direction);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -862,7 +863,7 @@ impl ContainerNode {
|
||||||
let sibling = match sibling {
|
let sibling = match sibling {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => {
|
None => {
|
||||||
if let Some(c) = self.parent.get().node_into_container() {
|
if let Some(c) = self.parent_container() {
|
||||||
c.move_focus_from_child(seat, self.deref(), direction);
|
c.move_focus_from_child(seat, self.deref(), direction);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -879,11 +880,12 @@ impl ContainerNode {
|
||||||
pub fn move_child(self: Rc<Self>, child: Rc<dyn ToplevelNode>, direction: Direction) {
|
pub fn move_child(self: Rc<Self>, child: Rc<dyn ToplevelNode>, direction: Direction) {
|
||||||
// CASE 1: This is the only child of the container. Replace the container by the child.
|
// CASE 1: This is the only child of the container. Replace the container by the child.
|
||||||
if self.num_children.get() == 1 {
|
if self.num_children.get() == 1 {
|
||||||
let parent = self.parent.get();
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
if !self.toplevel_data.is_fullscreen.get()
|
if !self.toplevel_data.is_fullscreen.get()
|
||||||
&& parent.cnode_accepts_child(child.tl_as_node())
|
&& parent.cnode_accepts_child(child.tl_as_node())
|
||||||
{
|
{
|
||||||
parent.cnode_replace_child(self.deref(), child.clone());
|
parent.cnode_replace_child(self.deref(), child.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -919,13 +921,13 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
// CASE 3: We're moving the child out of the container.
|
// CASE 3: We're moving the child out of the container.
|
||||||
let mut neighbor = self.clone();
|
let mut neighbor = self.clone();
|
||||||
let mut parent_opt = self.parent.get().node_into_container();
|
let mut parent_opt = self.parent_container();
|
||||||
while let Some(parent) = &parent_opt {
|
while let Some(parent) = &parent_opt {
|
||||||
if parent.split.get() == split {
|
if parent.split.get() == split {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
neighbor = parent.clone();
|
neighbor = parent.clone();
|
||||||
parent_opt = parent.parent.get().node_into_container();
|
parent_opt = parent.parent_container();
|
||||||
}
|
}
|
||||||
let parent = match parent_opt {
|
let parent = match parent_opt {
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
|
|
@ -947,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);
|
||||||
}
|
}
|
||||||
|
|
@ -968,9 +1024,9 @@ impl ContainerNode {
|
||||||
self.toplevel_data.wants_attention.set(set);
|
self.toplevel_data.wants_attention.set(set);
|
||||||
}
|
}
|
||||||
if propagate {
|
if propagate {
|
||||||
self.parent
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
.get()
|
parent.cnode_child_attention_request_changed(self, set);
|
||||||
.cnode_child_attention_request_changed(self, set);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1038,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) {
|
||||||
|
|
@ -1078,7 +1122,9 @@ impl Node for ContainerNode {
|
||||||
|
|
||||||
fn node_active_changed(&self, active: bool) {
|
fn node_active_changed(&self, active: bool) {
|
||||||
self.toplevel_data.active.set(active);
|
self.toplevel_data.active.set(active);
|
||||||
self.parent.get().node_child_active_changed(self, active, 1);
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
|
parent.node_child_active_changed(self, active, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|
@ -1109,35 +1155,14 @@ 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();
|
|
||||||
self.parent
|
|
||||||
.get()
|
|
||||||
.node_child_active_changed(self.deref(), active, depth + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>) {
|
||||||
|
|
@ -1308,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),
|
||||||
|
|
@ -1321,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 {
|
||||||
|
|
@ -1334,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);
|
||||||
|
|
@ -1349,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());
|
||||||
|
|
@ -1413,11 +1439,13 @@ 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 ToplevelNode for ContainerNode {
|
impl ToplevelNodeBase for ContainerNode {
|
||||||
tl_node_impl!();
|
|
||||||
|
|
||||||
fn tl_data(&self) -> &ToplevelData {
|
fn tl_data(&self) -> &ToplevelData {
|
||||||
&self.toplevel_data
|
&self.toplevel_data
|
||||||
}
|
}
|
||||||
|
|
@ -1430,11 +1458,7 @@ impl ToplevelNode for ContainerNode {
|
||||||
.map(|tl| tl.tl_into_node())
|
.map(|tl| tl.tl_into_node())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_after_parent_set(&self, parent: Rc<dyn ContainingNode>) {
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
self.parent.set(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<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);
|
||||||
}
|
}
|
||||||
|
|
@ -1452,9 +1476,9 @@ impl ToplevelNode for ContainerNode {
|
||||||
// log::info!("tl_change_extents");
|
// log::info!("tl_change_extents");
|
||||||
self.perform_layout();
|
self.perform_layout();
|
||||||
self.cancel_seat_ops();
|
self.cancel_seat_ops();
|
||||||
self.parent
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
.get()
|
parent.node_child_size_changed(self.deref(), rect.width(), rect.height());
|
||||||
.node_child_size_changed(self.deref(), rect.width(), rect.height());
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(c) = self.mono_child.get() {
|
if let Some(c) = self.mono_child.get() {
|
||||||
let body = self
|
let body = self
|
||||||
|
|
@ -1477,7 +1501,7 @@ impl ToplevelNode for ContainerNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_visible(&self, visible: bool) {
|
fn tl_set_visible_impl(&self, visible: bool) {
|
||||||
if let Some(mc) = self.mono_child.get() {
|
if let Some(mc) = self.mono_child.get() {
|
||||||
mc.node.tl_set_visible(visible);
|
mc.node.tl_set_visible(visible);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1485,11 +1509,9 @@ impl ToplevelNode for ContainerNode {
|
||||||
child.node.tl_set_visible(visible);
|
child.node.tl_set_visible(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.toplevel_data.set_visible(self, visible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_destroy(&self) {
|
fn tl_destroy_impl(&self) {
|
||||||
self.toplevel_data.destroy_node(self);
|
|
||||||
mem::take(self.seats.borrow_mut().deref_mut());
|
mem::take(self.seats.borrow_mut().deref_mut());
|
||||||
let mut cn = self.child_nodes.borrow_mut();
|
let mut cn = self.child_nodes.borrow_mut();
|
||||||
for (_, n) in cn.drain() {
|
for (_, n) in cn.drain() {
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use {
|
||||||
text::{self, TextTexture},
|
text::{self, TextTexture},
|
||||||
tree::{
|
tree::{
|
||||||
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
|
Direction, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData,
|
||||||
ToplevelNode,
|
ToplevelNode, ToplevelNodeBase,
|
||||||
},
|
},
|
||||||
utils::{errorfmt::ErrorFmt, smallmap::SmallMap},
|
utils::{errorfmt::ErrorFmt, smallmap::SmallMap},
|
||||||
},
|
},
|
||||||
|
|
@ -145,17 +145,11 @@ impl Node for PlaceholderNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToplevelNode for PlaceholderNode {
|
impl ToplevelNodeBase for PlaceholderNode {
|
||||||
tl_node_impl!();
|
|
||||||
|
|
||||||
fn tl_data(&self) -> &ToplevelData {
|
fn tl_data(&self) -> &ToplevelData {
|
||||||
&self.toplevel
|
&self.toplevel
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect) {
|
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect) {
|
||||||
self.toplevel.pos.set(*rect);
|
self.toplevel.pos.set(*rect);
|
||||||
if let Some(p) = self.toplevel.parent.get() {
|
if let Some(p) = self.toplevel.parent.get() {
|
||||||
|
|
@ -171,12 +165,15 @@ impl ToplevelNode for PlaceholderNode {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_visible(&self, visible: bool) {
|
fn tl_set_visible_impl(&self, _visible: bool) {
|
||||||
self.toplevel.set_visible(self, visible);
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_destroy(&self) {
|
fn tl_destroy_impl(&self) {
|
||||||
self.toplevel.destroy_node(self);
|
|
||||||
self.destroyed.set(true);
|
self.destroyed.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,27 +28,32 @@ use {
|
||||||
|
|
||||||
tree_id!(ToplevelNodeId);
|
tree_id!(ToplevelNodeId);
|
||||||
|
|
||||||
pub trait ToplevelNode: Node {
|
pub trait ToplevelNode: ToplevelNodeBase {
|
||||||
fn tl_as_node(&self) -> &dyn Node;
|
fn tl_as_node(&self) -> &dyn Node;
|
||||||
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||||
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
||||||
|
fn tl_surface_active_changed(&self, active: bool);
|
||||||
|
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool);
|
||||||
|
fn tl_title_changed(&self);
|
||||||
|
fn tl_set_parent(&self, parent: Rc<dyn ContainingNode>);
|
||||||
|
fn tl_extents_changed(&self);
|
||||||
|
fn tl_set_workspace(&self, ws: &Rc<WorkspaceNode>);
|
||||||
|
fn tl_change_extents(self: Rc<Self>, rect: &Rect);
|
||||||
|
fn tl_set_visible(&self, visible: bool);
|
||||||
|
fn tl_destroy(&self);
|
||||||
|
}
|
||||||
|
|
||||||
fn tl_data(&self) -> &ToplevelData;
|
impl<T: ToplevelNodeBase> ToplevelNode for T {
|
||||||
|
fn tl_as_node(&self) -> &dyn Node {
|
||||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
self
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||||
true
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_active(&self, active: bool) {
|
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||||
let _ = active;
|
self
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_on_activate(&self) {
|
|
||||||
// nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_surface_active_changed(&self, active: bool) {
|
fn tl_surface_active_changed(&self, active: bool) {
|
||||||
|
|
@ -70,13 +75,6 @@ pub trait ToplevelNode: Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_focus_child(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
|
||||||
self.tl_data()
|
|
||||||
.focus_node
|
|
||||||
.get(&seat)
|
|
||||||
.or_else(|| self.tl_default_focus_child())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool) {
|
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool) {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
if fullscreen {
|
if fullscreen {
|
||||||
|
|
@ -92,7 +90,7 @@ pub trait ToplevelNode: Node {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
let title = data.title.borrow_mut();
|
let title = data.title.borrow_mut();
|
||||||
if let Some(parent) = data.parent.get() {
|
if let Some(parent) = data.parent.get() {
|
||||||
parent.node_child_title_changed(self.tl_as_node(), &title);
|
parent.node_child_title_changed(self, &title);
|
||||||
}
|
}
|
||||||
if let Some(data) = data.fullscrceen_data.borrow_mut().deref() {
|
if let Some(data) = data.fullscrceen_data.borrow_mut().deref() {
|
||||||
*data.placeholder.tl_data().title.borrow_mut() = title.clone();
|
*data.placeholder.tl_data().title.borrow_mut() = title.clone();
|
||||||
|
|
@ -104,50 +102,24 @@ pub trait ToplevelNode: Node {
|
||||||
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();
|
|
||||||
self.tl_after_parent_set(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_after_parent_set(&self, parent: Rc<dyn ContainingNode>) {
|
|
||||||
let _ = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_workspace_ext(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
|
||||||
let _ = ws;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||||
let data = self.tl_data();
|
let data = self.tl_data();
|
||||||
if data.is_floating.get() {
|
if data.is_floating.get() {
|
||||||
|
|
@ -157,19 +129,56 @@ pub trait ToplevelNode: Node {
|
||||||
self.tl_change_extents_impl(rect)
|
self.tl_change_extents_impl(rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect);
|
fn tl_set_visible(&self, visible: bool) {
|
||||||
|
self.tl_set_visible_impl(visible);
|
||||||
|
self.tl_data().set_visible(self, visible);
|
||||||
|
}
|
||||||
|
|
||||||
fn tl_close(self: Rc<Self>) {
|
fn tl_destroy(&self) {
|
||||||
|
self.tl_data().destroy_node(self);
|
||||||
|
self.tl_destroy_impl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ToplevelNodeBase: Node {
|
||||||
|
fn tl_data(&self) -> &ToplevelData;
|
||||||
|
|
||||||
|
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tl_set_active(&self, active: bool) {
|
||||||
|
let _ = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tl_on_activate(&self) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tl_set_visible(&self, visible: bool);
|
fn tl_focus_child(&self, seat: SeatId) -> Option<Rc<dyn Node>> {
|
||||||
fn tl_destroy(&self);
|
self.tl_data()
|
||||||
|
.focus_node
|
||||||
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
.get(&seat)
|
||||||
self.tl_into_dyn()
|
.or_else(|| self.tl_default_focus_child())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tl_set_workspace_ext(&self, ws: &Rc<WorkspaceNode>) {
|
||||||
|
let _ = ws;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tl_change_extents_impl(self: Rc<Self>, rect: &Rect);
|
||||||
|
|
||||||
|
fn tl_close(self: Rc<Self>);
|
||||||
|
|
||||||
|
fn tl_set_visible_impl(&self, visible: bool);
|
||||||
|
fn tl_destroy_impl(&self);
|
||||||
|
|
||||||
|
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
||||||
|
|
||||||
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
fn tl_scanout_surface(&self) -> Option<Rc<WlSurface>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
@ -232,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();
|
||||||
|
|
@ -351,6 +364,10 @@ impl ToplevelData {
|
||||||
}
|
}
|
||||||
Some(p) => p,
|
Some(p) => p,
|
||||||
};
|
};
|
||||||
|
if parent.node_is_workspace() {
|
||||||
|
log::warn!("Cannot fullscreen root container in a workspace");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
||||||
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
|
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
|
||||||
let mut kb_foci = Default::default();
|
let mut kb_foci = Default::default();
|
||||||
|
|
@ -370,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