autocommit 2022-04-20 14:58:34 CEST
This commit is contained in:
parent
c1773c0fee
commit
fa1ec0b36c
22 changed files with 583 additions and 185 deletions
|
|
@ -682,17 +682,23 @@ impl ContainerNode {
|
|||
}
|
||||
|
||||
fn activate_child(self: &Rc<Self>, child: &NodeRef<ContainerChild>) {
|
||||
self.activate_child2(child, false);
|
||||
}
|
||||
|
||||
fn activate_child2(self: &Rc<Self>, child: &NodeRef<ContainerChild>, preserve_focus: bool) {
|
||||
if let Some(mc) = self.mono_child.get() {
|
||||
if mc.node.node_id() == child.node.node_id() {
|
||||
return;
|
||||
}
|
||||
let seats = collect_kb_foci(mc.node.clone());
|
||||
mc.node.node_set_visible(false);
|
||||
for seat in seats {
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
if !preserve_focus {
|
||||
let seats = collect_kb_foci(mc.node.clone());
|
||||
mc.node.node_set_visible(false);
|
||||
for seat in seats {
|
||||
child
|
||||
.node
|
||||
.clone()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
self.mono_child.set(Some(child.clone()));
|
||||
child.node.node_set_visible(true);
|
||||
|
|
@ -789,14 +795,6 @@ impl SizedNode for ContainerNode {
|
|||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
let parent = self.parent.get();
|
||||
if parent.node_id() == other {
|
||||
return true;
|
||||
}
|
||||
parent.node_is_contained_in(other)
|
||||
}
|
||||
|
||||
fn child_title_changed(self: &Rc<Self>, child: &dyn Node, title: &str) {
|
||||
let child = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(cn) => cn.to_ref(),
|
||||
|
|
@ -899,9 +897,9 @@ impl SizedNode for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn close(&self) {
|
||||
fn close(self: &Rc<Self>) {
|
||||
for child in self.children.iter() {
|
||||
child.node.node_close();
|
||||
child.node.clone().node_close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -985,7 +983,7 @@ impl SizedNode for ContainerNode {
|
|||
}
|
||||
let (split, prev) = direction_to_split(direction);
|
||||
// CASE 2: We're moving the child within the container.
|
||||
if split == self.split.get() {
|
||||
if split == self.split.get() || (split == ContainerSplit::Horizontal && self.mono_child.get().is_some()) {
|
||||
let cc = match self.child_nodes.borrow_mut().get(&child.node_id()) {
|
||||
Some(l) => l.to_ref(),
|
||||
None => return,
|
||||
|
|
@ -996,7 +994,7 @@ impl SizedNode for ContainerNode {
|
|||
};
|
||||
if let Some(neighbor) = neighbor {
|
||||
if neighbor.node.node_accepts_child(&*child) {
|
||||
self.remove_child(&*child);
|
||||
self.remove_child2(&*child, true);
|
||||
neighbor.node.clone().node_insert_child(child, direction);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1022,7 +1020,7 @@ impl SizedNode for ContainerNode {
|
|||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
self.clone().node_remove_child(&*child);
|
||||
self.remove_child2(&*child, true);
|
||||
match prev {
|
||||
true => parent.add_child_before(&*neighbor, child.clone()),
|
||||
false => parent.add_child_after(&*neighbor, child.clone()),
|
||||
|
|
@ -1151,7 +1149,7 @@ impl SizedNode for ContainerNode {
|
|||
|
||||
fn toggle_floating(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
let parent = self.parent.get();
|
||||
parent.clone().node_remove_child(self.deref());
|
||||
parent.clone().node_remove_child2(self.deref(), true);
|
||||
if parent.node_is_float() {
|
||||
self.state.map_tiled(self.clone());
|
||||
} else {
|
||||
|
|
@ -1192,7 +1190,10 @@ impl SizedNode for ContainerNode {
|
|||
fn replace_child(self: &Rc<Self>, old: &dyn Node, new: Rc<dyn Node>) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&old.node_id()) {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
None => {
|
||||
log::error!("Trying to replace a node that isn't a child of this container");
|
||||
return
|
||||
},
|
||||
};
|
||||
let (have_mc, was_mc) = match self.mono_child.get() {
|
||||
None => (false, false),
|
||||
|
|
@ -1209,6 +1210,7 @@ impl SizedNode for ContainerNode {
|
|||
title_rect: Cell::new(node.title_rect.get()),
|
||||
focus_history: Cell::new(None),
|
||||
});
|
||||
new.node_set_visible(node.node.node_visible());
|
||||
drop(node);
|
||||
let mut body = None;
|
||||
if was_mc {
|
||||
|
|
@ -1226,7 +1228,7 @@ impl SizedNode for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_child(self: &Rc<Self>, child: &dyn Node) {
|
||||
fn remove_child2(self: &Rc<Self>, child: &dyn Node, preserve_focus: bool) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&child.node_id()) {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
|
|
@ -1242,7 +1244,7 @@ impl SizedNode for ContainerNode {
|
|||
}
|
||||
}
|
||||
if let Some(child) = &new {
|
||||
self.activate_child(child);
|
||||
self.activate_child2(child, preserve_focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use {
|
|||
cursor::KnownCursor,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
zwlr_layer_shell_v1::{OVERLAY, TOP},
|
||||
},
|
||||
rect::Rect,
|
||||
render::Renderer,
|
||||
|
|
@ -114,47 +113,7 @@ impl SizedNode for DisplayNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
if output.find_layer_surface_at(x, y, &[OVERLAY, TOP], tree)
|
||||
== FindTreeResult::AcceptsInput
|
||||
{
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
tree.pop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for stacked in self.stacked.rev_iter() {
|
||||
let ext = stacked.node_absolute_position();
|
||||
if stacked.node_absolute_position_constrains_input() && !ext.contains(x, y) {
|
||||
// TODO: make constrain always true
|
||||
continue;
|
||||
}
|
||||
let (x, y) = ext.translate(x, y);
|
||||
let idx = tree.len();
|
||||
tree.push(FoundNode {
|
||||
node: stacked.deref().clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
match stacked.node_find_tree_at(x, y, tree) {
|
||||
FindTreeResult::AcceptsInput => {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
FindTreeResult::Other => {
|
||||
tree.drain(idx..);
|
||||
}
|
||||
}
|
||||
}
|
||||
for output in outputs.values() {
|
||||
let pos = output.global.pos.get();
|
||||
if pos.contains(x, y) {
|
||||
let (x, y) = pos.translate(x, y);
|
||||
tree.push(FoundNode {
|
||||
node: output.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
output.node_find_tree_at(x, y, tree);
|
||||
output.find_tree_at(x, y, tree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,6 +430,8 @@ impl SizedNode for FloatNode {
|
|||
}
|
||||
} else if state == KeyState::Released {
|
||||
seat_data.op_active = false;
|
||||
let ws = seat.get_output().ensure_workspace();
|
||||
self.set_workspace(&ws);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +467,7 @@ impl SizedNode for FloatNode {
|
|||
self.schedule_layout();
|
||||
}
|
||||
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child2(self: &Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
||||
self.child.set(None);
|
||||
self.display_link.set(None);
|
||||
self.workspace_link.set(None);
|
||||
|
|
|
|||
74
src/tree/fullscreen.rs
Normal file
74
src/tree/fullscreen.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use crate::tree::{PlaceholderNode, Node, WorkspaceNode, SizedNode};
|
||||
|
||||
pub trait SizedFullscreenNode: SizedNode {
|
||||
fn data(&self) -> &FullscreenData;
|
||||
fn on_set_fullscreen(&self, workspace: &Rc<WorkspaceNode>);
|
||||
fn on_unset_fullscreen(&self);
|
||||
fn title(&self) -> String;
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FullscreenNode {
|
||||
fn data(&self) -> &FullscreenData;
|
||||
fn on_set_fullscreen(&self, workspace: &Rc<WorkspaceNode>);
|
||||
fn on_unset_fullscreen(&self);
|
||||
fn as_node(&self) -> &dyn Node;
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn title(&self) -> String;
|
||||
}
|
||||
|
||||
impl<T: SizedFullscreenNode> FullscreenNode for T {
|
||||
fn data(&self) -> &FullscreenData {
|
||||
<Self as SizedFullscreenNode>::data(self)
|
||||
}
|
||||
|
||||
fn on_set_fullscreen(&self, workspace: &Rc<WorkspaceNode>) {
|
||||
<Self as SizedFullscreenNode>::on_set_fullscreen(self, workspace)
|
||||
}
|
||||
|
||||
fn on_unset_fullscreen(&self) {
|
||||
<Self as SizedFullscreenNode>::on_unset_fullscreen(self)
|
||||
}
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
<Self as SizedFullscreenNode>::as_node(self)
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
<Self as SizedFullscreenNode>::into_node(self)
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
<Self as SizedFullscreenNode>::title(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FullscreenedData {
|
||||
pub placeholder: Rc<PlaceholderNode>,
|
||||
pub workspace: Rc<WorkspaceNode>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FullscreenData {
|
||||
pub is_fullscreen: Cell<bool>,
|
||||
pub data: RefCell<Option<FullscreenedData>>,
|
||||
}
|
||||
|
||||
impl FullscreenData {
|
||||
pub fn set_title(&self, title: &str) {
|
||||
let data = self.data.borrow_mut();
|
||||
if let Some(data) = data.deref() {
|
||||
data.placeholder.set_title(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ use {
|
|||
rc::Rc,
|
||||
},
|
||||
};
|
||||
use crate::ifs::zwlr_layer_shell_v1::{OVERLAY, TOP};
|
||||
|
||||
tree_id!(OutputNodeId);
|
||||
pub struct OutputNode {
|
||||
|
|
@ -139,6 +140,7 @@ impl OutputNode {
|
|||
name: name.clone(),
|
||||
output_link: Default::default(),
|
||||
visible: Cell::new(true),
|
||||
fullscreen: Default::default(),
|
||||
});
|
||||
self.state.workspaces.set(name, workspace.clone());
|
||||
workspace
|
||||
|
|
@ -325,6 +327,48 @@ impl SizedNode for OutputNode {
|
|||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, mut y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
if let Some(fs) = ws.fullscreen.get() {
|
||||
tree.push(FoundNode {
|
||||
node: fs.clone().into_node(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
return fs.as_node().node_find_tree_at(x, y, tree);
|
||||
}
|
||||
}
|
||||
let (x_abs, y_abs) = self.global.pos.get().translate_inv(x, y);
|
||||
{
|
||||
if self.find_layer_surface_at(x_abs, y_abs, &[OVERLAY, TOP], tree)
|
||||
== FindTreeResult::AcceptsInput
|
||||
{
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
}
|
||||
{
|
||||
for stacked in self.state.root.stacked.rev_iter() {
|
||||
let ext = stacked.node_absolute_position();
|
||||
if stacked.node_absolute_position_constrains_input() && !ext.contains(x_abs, y_abs) {
|
||||
// TODO: make constrain always true
|
||||
continue;
|
||||
}
|
||||
let (x, y) = ext.translate(x_abs, y_abs);
|
||||
let idx = tree.len();
|
||||
tree.push(FoundNode {
|
||||
node: stacked.deref().clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
match stacked.node_find_tree_at(x, y, tree) {
|
||||
FindTreeResult::AcceptsInput => {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
FindTreeResult::Other => {
|
||||
tree.truncate(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let bar_height = self.state.theme.title_height.get() + 1;
|
||||
if y > bar_height {
|
||||
y -= bar_height;
|
||||
|
|
@ -344,7 +388,7 @@ impl SizedNode for OutputNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child2(self: &Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
|
|
|||
183
src/tree/placeholder.rs
Normal file
183
src/tree/placeholder.rs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use jay_config::Direction;
|
||||
use crate::client::{Client};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::rect::Rect;
|
||||
use crate::state::State;
|
||||
use crate::tree::{FindTreeResult, FoundNode, FullscreenNode, Node, NodeId, NodeVisitor, SizedNode, ToplevelData, ToplevelNode, WorkspaceNode};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
|
||||
tree_id!(DetachedNodeId);
|
||||
pub struct PlaceholderNode {
|
||||
id: DetachedNodeId,
|
||||
state: Rc<State>,
|
||||
seat_state: NodeSeatState,
|
||||
parent: CloneCell<Option<Rc<dyn Node>>>,
|
||||
workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
title: RefCell<String>,
|
||||
visible: Cell<bool>,
|
||||
pos: Cell<Rect>,
|
||||
client: Option<Rc<Client>>,
|
||||
toplevel: ToplevelData,
|
||||
active: Cell<bool>,
|
||||
destroyed: Cell<bool>,
|
||||
}
|
||||
|
||||
impl PlaceholderNode {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn FullscreenNode>) -> Self {
|
||||
Self {
|
||||
id: state.node_ids.next(),
|
||||
state: state.clone(),
|
||||
seat_state: Default::default(),
|
||||
parent: Default::default(),
|
||||
workspace: Default::default(),
|
||||
title: RefCell::new(node.title()),
|
||||
visible: Default::default(),
|
||||
pos: Default::default(),
|
||||
client: node.as_node().node_client(),
|
||||
toplevel: Default::default(),
|
||||
active: Default::default(),
|
||||
destroyed: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_title(&self, title: &str) {
|
||||
*self.title.borrow_mut() = title.to_string();
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.node_child_title_changed(self, title);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_destroyed(&self) -> bool {
|
||||
self.destroyed.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedNode for PlaceholderNode {
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.node_remove_child(self);
|
||||
}
|
||||
}
|
||||
self.parent.take();
|
||||
self.workspace.take();
|
||||
self.seat_state.destroy_node(self);
|
||||
self.destroyed.set(true);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_placeholder(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, _visitor: &mut dyn NodeVisitor) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn close(self: &Rc<Self>) {
|
||||
let slf = self.clone();
|
||||
self.state.run_toplevel.schedule(move || {
|
||||
slf.destroy_node(true);
|
||||
});
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
|
||||
fn active_changed(&self, active: bool) {
|
||||
self.active.set(active);
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, _x: i32, _y: i32, _tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
self.pos.set(*rect);
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
}
|
||||
|
||||
fn set_parent(self: &Rc<Self>, parent: Rc<dyn Node>) {
|
||||
self.parent.set(Some(parent.clone()));
|
||||
parent.node_child_title_changed(self.deref(), self.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
self.client.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToplevelNode for PlaceholderNode {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
&self.toplevel
|
||||
}
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
self
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn set_active(&self, _active: bool) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -13,11 +13,9 @@ pub trait ToplevelNode {
|
|||
fn as_node(&self) -> &dyn Node;
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn accepts_keyboard_focus(&self) -> bool;
|
||||
fn default_surface(&self) -> Rc<WlSurface>;
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>>;
|
||||
fn set_active(&self, active: bool);
|
||||
fn activate(&self);
|
||||
fn toggle_floating(self: Rc<Self>);
|
||||
fn close(&self);
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -61,11 +59,11 @@ impl<'a> dyn ToplevelNode + 'a {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: SeatId) -> Rc<WlSurface> {
|
||||
pub fn focus_surface(&self, seat: SeatId) -> Option<Rc<WlSurface>> {
|
||||
self.data()
|
||||
.focus_surface
|
||||
.get(&seat)
|
||||
.unwrap_or_else(|| self.default_surface())
|
||||
.or_else(|| self.default_surface())
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use {
|
|||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
use crate::tree::PlaceholderNode;
|
||||
|
||||
pub trait NodeVisitorBase: Sized {
|
||||
fn visit_surface(&mut self, node: &Rc<WlSurface>) {
|
||||
|
|
@ -51,6 +52,10 @@ pub trait NodeVisitorBase: Sized {
|
|||
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_placeholder(&mut self, node: &Rc<PlaceholderNode>) {
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait NodeVisitor {
|
||||
|
|
@ -64,6 +69,7 @@ pub trait NodeVisitor {
|
|||
fn visit_workspace(&mut self, node: &Rc<WorkspaceNode>);
|
||||
fn visit_layer_surface(&mut self, node: &Rc<ZwlrLayerSurfaceV1>);
|
||||
fn visit_xwindow(&mut self, node: &Rc<Xwindow>);
|
||||
fn visit_placeholder(&mut self, node: &Rc<PlaceholderNode>);
|
||||
}
|
||||
|
||||
impl<T: NodeVisitorBase> NodeVisitor for T {
|
||||
|
|
@ -106,6 +112,10 @@ impl<T: NodeVisitorBase> NodeVisitor for T {
|
|||
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
|
||||
<T as NodeVisitorBase>::visit_xwindow(self, node)
|
||||
}
|
||||
|
||||
fn visit_placeholder(&mut self, node: &Rc<PlaceholderNode>) {
|
||||
<T as NodeVisitorBase>::visit_placeholder(self, node)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GenericNodeVisitor<F> {
|
||||
|
|
@ -166,6 +176,11 @@ impl<F: FnMut(Rc<dyn Node>)> NodeVisitor for GenericNodeVisitor<F> {
|
|||
(self.f)(node.clone());
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
|
||||
fn visit_placeholder(&mut self, node: &Rc<PlaceholderNode>) {
|
||||
(self.f)(node.clone());
|
||||
node.node_visit_children(self);
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn visit_containers<F: FnMut(&Rc<ContainerNode>)>(f: F) -> impl NodeVisitor {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use {
|
|||
jay_config::Direction,
|
||||
std::{cell::Cell, fmt::Debug, rc::Rc},
|
||||
};
|
||||
use crate::tree::FullscreenNode;
|
||||
|
||||
tree_id!(WorkspaceNodeId);
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ pub struct WorkspaceNode {
|
|||
pub name: String,
|
||||
pub output_link: Cell<Option<LinkedNode<Rc<WorkspaceNode>>>>,
|
||||
pub visible: Cell<bool>,
|
||||
pub fullscreen: CloneCell<Option<Rc<dyn FullscreenNode>>>,
|
||||
}
|
||||
|
||||
impl WorkspaceNode {
|
||||
|
|
@ -69,6 +71,9 @@ impl SizedNode for WorkspaceNode {
|
|||
if let Some(c) = self.container.get() {
|
||||
visitor.visit_container(&c);
|
||||
}
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.into_node().node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
|
|
@ -116,7 +121,7 @@ impl SizedNode for WorkspaceNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child(self: &Rc<Self>, _child: &dyn Node) {
|
||||
fn remove_child2(self: &Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
||||
self.container.set(None);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue