autocommit 2022-04-23 00:55:20 CEST
This commit is contained in:
parent
436f383cd6
commit
e3b3d848c3
32 changed files with 1773 additions and 2451 deletions
File diff suppressed because it is too large
Load diff
17
src/tree/containing.rs
Normal file
17
src/tree/containing.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use {
|
||||
crate::tree::{Node, ToplevelNode},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub trait ContainingNode: Node {
|
||||
fn cnode_as_node(&self) -> &dyn Node;
|
||||
fn cnode_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn cnode_into_dyn(self: Rc<Self>) -> Rc<dyn ContainingNode>;
|
||||
|
||||
fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>);
|
||||
fn cnode_remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
self.cnode_remove_child2(child, false);
|
||||
}
|
||||
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, preserve_focus: bool);
|
||||
fn cnode_accepts_child(&self, node: &dyn Node) -> bool;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ use {
|
|||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode, SizedNode,
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode, StackedNode,
|
||||
},
|
||||
utils::{copyhashmap::CopyHashMap, linkedlist::LinkedList},
|
||||
},
|
||||
|
|
@ -17,7 +17,7 @@ pub struct DisplayNode {
|
|||
pub id: NodeId,
|
||||
pub extents: Cell<Rect>,
|
||||
pub outputs: CopyHashMap<ConnectorId, Rc<OutputNode>>,
|
||||
pub stacked: LinkedList<Rc<dyn Node>>,
|
||||
pub stacked: LinkedList<Rc<dyn StackedNode>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
}
|
||||
|
||||
|
|
@ -57,32 +57,20 @@ impl DisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for DisplayNode {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for DisplayNode {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let mut outputs = self.outputs.lock();
|
||||
for output in outputs.values() {
|
||||
output.node_destroy(false);
|
||||
}
|
||||
outputs.clear();
|
||||
for stacked in self.stacked.iter() {
|
||||
stacked.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_display(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_display(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
let outputs = self.outputs.lock();
|
||||
for (_, output) in outputs.deref() {
|
||||
visitor.visit_output(output);
|
||||
|
|
@ -92,15 +80,15 @@ impl SizedNode for DisplayNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.extents.get()
|
||||
}
|
||||
|
||||
fn 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 {
|
||||
let outputs = self.outputs.lock();
|
||||
for output in outputs.values() {
|
||||
let pos = output.global.pos.get();
|
||||
|
|
@ -111,18 +99,18 @@ impl SizedNode for DisplayNode {
|
|||
x,
|
||||
y,
|
||||
});
|
||||
output.find_tree_at(x, y, tree);
|
||||
output.node_find_tree_at(x, y, tree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_display(self, x, y);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use {
|
|||
text,
|
||||
theme::Color,
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, SizedNode, WorkspaceNode,
|
||||
walker::NodeVisitor, ContainingNode, FindTreeResult, FoundNode, Node, NodeId,
|
||||
StackedNode, ToplevelNode, WorkspaceNode,
|
||||
},
|
||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedNode},
|
||||
},
|
||||
|
|
@ -30,10 +31,10 @@ pub struct FloatNode {
|
|||
pub state: Rc<State>,
|
||||
pub visible: Cell<bool>,
|
||||
pub position: Cell<Rect>,
|
||||
pub display_link: Cell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
pub workspace_link: Cell<Option<LinkedNode<Rc<dyn Node>>>>,
|
||||
pub display_link: Cell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pub workspace_link: Cell<Option<LinkedNode<Rc<dyn StackedNode>>>>,
|
||||
pub workspace: CloneCell<Rc<WorkspaceNode>>,
|
||||
pub child: CloneCell<Option<Rc<dyn Node>>>,
|
||||
pub child: CloneCell<Option<Rc<dyn ToplevelNode>>>,
|
||||
pub active: Cell<bool>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub layout_scheduled: Cell<bool>,
|
||||
|
|
@ -90,7 +91,7 @@ impl FloatNode {
|
|||
state: &Rc<State>,
|
||||
ws: &Rc<WorkspaceNode>,
|
||||
position: Rect,
|
||||
child: Rc<dyn Node>,
|
||||
child: Rc<dyn ToplevelNode>,
|
||||
) -> Rc<Self> {
|
||||
let floater = Rc::new(FloatNode {
|
||||
id: state.node_ids.next(),
|
||||
|
|
@ -115,8 +116,8 @@ impl FloatNode {
|
|||
floater
|
||||
.workspace_link
|
||||
.set(Some(ws.stacked.add_last(floater.clone())));
|
||||
child.clone().node_set_workspace(ws);
|
||||
child.clone().node_set_parent(floater.clone());
|
||||
child.clone().tl_set_workspace(ws);
|
||||
child.tl_set_parent(floater.clone());
|
||||
floater.schedule_layout();
|
||||
floater
|
||||
}
|
||||
|
|
@ -151,7 +152,7 @@ impl FloatNode {
|
|||
(pos.height() - 2 * bw - th - 1).max(0),
|
||||
)
|
||||
.unwrap();
|
||||
child.clone().node_change_extents(&cpos);
|
||||
child.clone().tl_change_extents(&cpos);
|
||||
self.layout_scheduled.set(false);
|
||||
self.schedule_render_titles();
|
||||
}
|
||||
|
|
@ -312,6 +313,23 @@ impl FloatNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.tl_set_workspace(ws);
|
||||
}
|
||||
self.workspace_link
|
||||
.set(Some(ws.stacked.add_last(self.clone())));
|
||||
self.workspace.set(ws.clone());
|
||||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(child) = self.child.get() {
|
||||
child.tl_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for FloatNode {
|
||||
|
|
@ -320,55 +338,34 @@ impl Debug for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for FloatNode {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for FloatNode {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
let _v = self.display_link.take();
|
||||
let _v = self.workspace_link.take();
|
||||
if let Some(child) = self.child.get() {
|
||||
child.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_float(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_float(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.workspace.get())
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.position.get()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(child) = self.child.get() {
|
||||
child.node_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn 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();
|
||||
if t.deref() != title {
|
||||
t.clear();
|
||||
|
|
@ -377,12 +374,41 @@ impl SizedNode for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.position.get()
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let theme = &self.state.theme;
|
||||
let th = theme.title_height.get();
|
||||
let bw = theme.border_width.get();
|
||||
let pos = self.position.get();
|
||||
if x < bw || x >= pos.width() - bw {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
if y < bw + th + 1 || y >= pos.height() - bw {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
let child = match self.child.get() {
|
||||
Some(c) => c,
|
||||
_ => return FindTreeResult::Other,
|
||||
};
|
||||
let x = x - bw;
|
||||
let y = y - bw - th - 1;
|
||||
tree.push(FoundNode {
|
||||
node: child.clone().tl_into_node(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
child.node_find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn button(
|
||||
self: &Rc<Self>,
|
||||
fn node_child_active_changed(self: Rc<Self>, _child: &dyn Node, active: bool, _depth: u32) {
|
||||
self.active.set(active);
|
||||
}
|
||||
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_floating(self, x, y)
|
||||
}
|
||||
|
||||
fn node_on_button(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
button: u32,
|
||||
state: KeyState,
|
||||
|
|
@ -435,60 +461,18 @@ impl SizedNode for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let theme = &self.state.theme;
|
||||
let th = theme.title_height.get();
|
||||
let bw = theme.border_width.get();
|
||||
let pos = self.position.get();
|
||||
if x < bw || x >= pos.width() - bw {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
if y < bw + th + 1 || y >= pos.height() - bw {
|
||||
return FindTreeResult::AcceptsInput;
|
||||
}
|
||||
let child = match self.child.get() {
|
||||
Some(c) => c,
|
||||
_ => return FindTreeResult::Other,
|
||||
};
|
||||
let x = x - bw;
|
||||
let y = y - bw - th - 1;
|
||||
tree.push(FoundNode {
|
||||
node: child.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
child.node_find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn replace_child(self: &Rc<Self>, _old: &dyn Node, new: Rc<dyn Node>) {
|
||||
self.child.set(Some(new.clone()));
|
||||
new.clone().node_set_parent(self.clone());
|
||||
new.clone().node_set_workspace(&self.workspace.get());
|
||||
self.schedule_layout();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
fn child_active_changed(self: &Rc<Self>, _child: &dyn Node, active: bool, _depth: u32) {
|
||||
self.active.set(active);
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
fn pointer_unfocus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
fn node_on_pointer_unfocus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let mut seats = self.seats.borrow_mut();
|
||||
if let Some(seat_state) = seats.get_mut(&seat.id()) {
|
||||
seat_state.target = false;
|
||||
}
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
let mut seats = self.seats.borrow_mut();
|
||||
if let Some(seat_state) = seats.get_mut(&seat.id()) {
|
||||
seat_state.target = true;
|
||||
|
|
@ -496,32 +480,44 @@ impl SizedNode for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn pointer_motion(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
fn node_on_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_floating(self, x, y)
|
||||
}
|
||||
|
||||
fn into_float(self: &Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
fn node_into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn accepts_child(&self, _node: &dyn Node) -> bool {
|
||||
true
|
||||
fn node_into_containing_node(self: Rc<Self>) -> Option<Rc<dyn ContainingNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn is_float(&self) -> bool {
|
||||
fn node_is_float(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
if let Some(c) = self.child.get() {
|
||||
c.node_set_workspace(ws);
|
||||
}
|
||||
self.workspace_link
|
||||
.set(Some(ws.stacked.add_last(self.clone())));
|
||||
self.workspace.set(ws.clone());
|
||||
}
|
||||
}
|
||||
|
||||
impl ContainingNode for FloatNode {
|
||||
containing_node_impl!();
|
||||
|
||||
fn cnode_replace_child(self: Rc<Self>, _old: &dyn Node, new: Rc<dyn ToplevelNode>) {
|
||||
self.child.set(Some(new.clone()));
|
||||
new.tl_set_parent(self.clone());
|
||||
new.clone().tl_set_workspace(&self.workspace.get());
|
||||
self.schedule_layout();
|
||||
}
|
||||
|
||||
fn cnode_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);
|
||||
}
|
||||
|
||||
fn cnode_accepts_child(&self, _node: &dyn Node) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl StackedNode for FloatNode {
|
||||
stacked_node_impl!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,182 +0,0 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_seat::collect_kb_foci,
|
||||
state::State,
|
||||
tree::{Node, OutputNode, PlaceholderNode, SizedNode, WorkspaceNode},
|
||||
},
|
||||
jay_config::Direction,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
||||
pub trait SizedFullscreenNode: SizedNode {
|
||||
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 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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FullscreenData {
|
||||
pub fn set_fullscreen(
|
||||
&self,
|
||||
state: &Rc<State>,
|
||||
node: Rc<dyn FullscreenNode>,
|
||||
output: &Rc<OutputNode>,
|
||||
) {
|
||||
let ws = output.ensure_workspace();
|
||||
if ws.fullscreen.get().is_some() {
|
||||
log::info!("Cannot fullscreen a node on a workspace that already has a fullscreen node attached");
|
||||
return;
|
||||
}
|
||||
let mut data = self.data.borrow_mut();
|
||||
if data.is_some() {
|
||||
log::info!("Cannot fullscreen a node that is already fullscreen");
|
||||
return;
|
||||
}
|
||||
let parent = match node.as_node().node_parent() {
|
||||
None => {
|
||||
log::warn!("Cannot fullscreen a node without a parent");
|
||||
return;
|
||||
}
|
||||
Some(p) => p,
|
||||
};
|
||||
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
||||
parent.node_replace_child(node.as_node(), placeholder.clone());
|
||||
let mut kb_foci = Default::default();
|
||||
if let Some(container) = ws.container.get() {
|
||||
kb_foci = collect_kb_foci(container.clone());
|
||||
container.set_visible(false);
|
||||
}
|
||||
*data = Some(FullscreenedData {
|
||||
placeholder,
|
||||
workspace: ws.clone(),
|
||||
});
|
||||
self.is_fullscreen.set(true);
|
||||
ws.fullscreen.set(Some(node.clone()));
|
||||
node.clone().into_node().node_set_parent(ws.clone());
|
||||
node.clone().into_node().node_set_workspace(&ws);
|
||||
node.clone()
|
||||
.into_node()
|
||||
.node_change_extents(&output.global.pos.get());
|
||||
for seat in kb_foci {
|
||||
node.clone()
|
||||
.into_node()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
node.on_set_fullscreen(&ws);
|
||||
}
|
||||
|
||||
pub fn unset_fullscreen(&self, state: &Rc<State>, node: Rc<dyn FullscreenNode>) {
|
||||
if !self.is_fullscreen.get() {
|
||||
log::warn!("Cannot unset fullscreen on a node that is not fullscreen");
|
||||
return;
|
||||
}
|
||||
let fd = match self.data.borrow_mut().take() {
|
||||
Some(fd) => fd,
|
||||
_ => {
|
||||
log::error!("is_fullscreen = true but data is None");
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.is_fullscreen.set(false);
|
||||
match fd.workspace.fullscreen.get() {
|
||||
None => {
|
||||
log::error!("Node is supposed to be fullscreened on a workspace but workspace has not fullscreen node.");
|
||||
return;
|
||||
}
|
||||
Some(f) if f.as_node().node_id() != node.as_node().node_id() => {
|
||||
log::error!("Node is supposed to be fullscreened on a workspace but the workspace has a different node attached.");
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
fd.workspace.fullscreen.take();
|
||||
if let Some(container) = fd.workspace.container.get() {
|
||||
container.set_visible(node.as_node().node_visible());
|
||||
}
|
||||
if fd.placeholder.is_destroyed() {
|
||||
state.map_tiled(node.into_node());
|
||||
return;
|
||||
}
|
||||
let parent = fd.placeholder.parent().unwrap();
|
||||
parent.node_replace_child(fd.placeholder.deref(), node.clone().into_node());
|
||||
if node.as_node().node_visible() {
|
||||
let kb_foci = collect_kb_foci(fd.placeholder.clone());
|
||||
for seat in kb_foci {
|
||||
node.clone()
|
||||
.into_node()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
fd.placeholder
|
||||
.node_seat_state()
|
||||
.destroy_node(fd.placeholder.deref());
|
||||
node.on_unset_fullscreen();
|
||||
}
|
||||
|
||||
pub fn destroy_node(&self) {
|
||||
if let Some(fd) = self.data.borrow_mut().take() {
|
||||
fd.placeholder.destroy_node(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,9 +13,7 @@ use {
|
|||
state::State,
|
||||
text,
|
||||
theme::Color,
|
||||
tree::{
|
||||
walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, SizedNode, WorkspaceNode,
|
||||
},
|
||||
tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode},
|
||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedList},
|
||||
},
|
||||
jay_config::Direction,
|
||||
|
|
@ -157,16 +155,15 @@ impl OutputNode {
|
|||
return false;
|
||||
}
|
||||
collect_kb_foci2(old.clone(), &mut seats);
|
||||
old.node_set_visible(false);
|
||||
old.set_visible(false);
|
||||
}
|
||||
ws.node_set_visible(true);
|
||||
ws.set_visible(true);
|
||||
if let Some(fs) = ws.fullscreen.get() {
|
||||
fs.into_node().node_change_extents(&self.global.pos.get());
|
||||
fs.tl_change_extents(&self.global.pos.get());
|
||||
}
|
||||
ws.change_extents(&self.workspace_rect());
|
||||
let node = ws.last_active_child();
|
||||
for seat in seats {
|
||||
node.clone().node_do_focus(&seat, Direction::Unspecified);
|
||||
ws.clone().node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -208,13 +205,13 @@ impl OutputNode {
|
|||
self.update_render_data();
|
||||
if let Some(c) = self.workspace.get() {
|
||||
if let Some(fs) = c.fullscreen.get() {
|
||||
fs.into_node().node_change_extents(rect);
|
||||
fs.tl_change_extents(rect);
|
||||
}
|
||||
c.node_change_extents(&self.workspace_rect());
|
||||
c.change_extents(&self.workspace_rect());
|
||||
}
|
||||
for layer in &self.layers {
|
||||
for surface in layer.iter() {
|
||||
surface.deref().clone().node_change_extents(&rect);
|
||||
surface.compute_position();
|
||||
}
|
||||
}
|
||||
self.global.send_mode();
|
||||
|
|
@ -270,32 +267,20 @@ impl Debug for OutputNode {
|
|||
}
|
||||
}
|
||||
|
||||
impl SizedNode for OutputNode {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for OutputNode {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.state.root.remove_child(self);
|
||||
}
|
||||
self.workspace.set(None);
|
||||
let workspaces: Vec<_> = self.workspaces.iter().map(|e| e.deref().clone()).collect();
|
||||
for workspace in workspaces {
|
||||
workspace.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_output(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_output(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
for ws in self.workspaces.iter() {
|
||||
visitor.visit_workspace(ws.deref());
|
||||
}
|
||||
|
|
@ -306,40 +291,29 @@ impl SizedNode for OutputNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.state.root.clone())
|
||||
}
|
||||
|
||||
fn last_active_child(self: &Rc<Self>) -> Rc<dyn Node> {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
return ws.last_active_child();
|
||||
}
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
ws.do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.global.pos.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, mut y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
ws.node_do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn node_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(),
|
||||
node: fs.clone().tl_into_node(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
return fs.as_node().node_find_tree_at(x, y, tree);
|
||||
return fs.tl_as_node().node_find_tree_at(x, y, tree);
|
||||
}
|
||||
}
|
||||
{
|
||||
|
|
@ -352,7 +326,8 @@ impl SizedNode for OutputNode {
|
|||
let (x_abs, y_abs) = self.global.pos.get().translate_inv(x, y);
|
||||
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)
|
||||
if stacked.stacked_absolute_position_constrains_input()
|
||||
&& !ext.contains(x_abs, y_abs)
|
||||
{
|
||||
// TODO: make constrain always true
|
||||
continue;
|
||||
|
|
@ -360,7 +335,7 @@ impl SizedNode for OutputNode {
|
|||
let (x, y) = ext.translate(x_abs, y_abs);
|
||||
let idx = tree.len();
|
||||
tree.push(FoundNode {
|
||||
node: stacked.deref().clone(),
|
||||
node: stacked.deref().clone().stacked_into_node(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
|
|
@ -393,23 +368,19 @@ impl SizedNode for OutputNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child2(self: &Rc<Self>, _child: &dyn Node, _preserve_focus: bool) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_output(self, x, y);
|
||||
}
|
||||
|
||||
fn is_output(&self) -> bool {
|
||||
true
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn into_output(self: &Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
fn node_into_output(self: Rc<Self>) -> Option<Rc<OutputNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn node_is_output(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,60 +3,33 @@ use {
|
|||
client::Client,
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
ifs::wl_seat::{NodeSeatState, WlSeatGlobal},
|
||||
rect::Rect,
|
||||
render::{Renderer, Texture},
|
||||
state::State,
|
||||
text,
|
||||
theme::Color,
|
||||
tree::{
|
||||
FindTreeResult, FoundNode, FullscreenNode, Node, NodeId, NodeVisitor, SizedNode,
|
||||
SizedToplevelNode, ToplevelData, WorkspaceNode,
|
||||
},
|
||||
tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode},
|
||||
utils::{clonecell::CloneCell, errorfmt::ErrorFmt},
|
||||
},
|
||||
jay_config::Direction,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, rc::Rc},
|
||||
};
|
||||
|
||||
tree_id!(DetachedNodeId);
|
||||
tree_id!(PlaceholderNodeId);
|
||||
|
||||
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>>,
|
||||
id: PlaceholderNodeId,
|
||||
toplevel: ToplevelData,
|
||||
active: Cell<bool>,
|
||||
destroyed: Cell<bool>,
|
||||
texture: CloneCell<Option<Rc<Texture>>>,
|
||||
}
|
||||
|
||||
impl PlaceholderNode {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn FullscreenNode>) -> Self {
|
||||
pub fn new_for(state: &Rc<State>, node: Rc<dyn ToplevelNode>) -> 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(),
|
||||
toplevel: ToplevelData::new(state, node.tl_title(), node.node_client()),
|
||||
destroyed: Default::default(),
|
||||
texture: Default::default(),
|
||||
}
|
||||
|
|
@ -66,121 +39,91 @@ impl PlaceholderNode {
|
|||
self.texture.get()
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
pub fn position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedNode for PlaceholderNode {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for PlaceholderNode {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.toplevel.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 node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_placeholder(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_placeholder(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, _visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, _visitor: &mut dyn NodeVisitor) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
fn node_visible(&self) -> bool {
|
||||
self.toplevel.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.parent.get()
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.toplevel.pos.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) {
|
||||
fn node_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 move_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.node_move_focus_from_child(seat, self.deref(), direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn move_self(self: &Rc<Self>, direction: Direction) {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.node_move_child(self.clone(), direction);
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
self.toplevel.active.set(active);
|
||||
if let Some(parent) = self.toplevel.parent.get() {
|
||||
parent.node_child_active_changed(self, active, 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn 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 {
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn pointer_enter(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_placeholder(self, x, y);
|
||||
}
|
||||
|
||||
fn node_client(&self) -> Option<Rc<Client>> {
|
||||
self.toplevel.client.clone()
|
||||
}
|
||||
|
||||
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_placeholder(self, x, y);
|
||||
fn node_is_placeholder(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl ToplevelNode for PlaceholderNode {
|
||||
tl_node_impl!();
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData {
|
||||
&self.toplevel
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
self.pos.set(*rect);
|
||||
if let Some(p) = self.parent.get() {
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
self.toplevel.pos.set(*rect);
|
||||
if let Some(p) = self.toplevel.parent.get() {
|
||||
p.node_child_size_changed(self.deref(), rect.width(), rect.height());
|
||||
}
|
||||
self.texture.set(None);
|
||||
if let Some(ctx) = self.state.render_ctx.get() {
|
||||
if let Some(ctx) = self.toplevel.state.render_ctx.get() {
|
||||
if rect.width() != 0 && rect.height() != 0 {
|
||||
let font = format!("monospace {}", rect.width() / 10);
|
||||
match text::render_fitting(
|
||||
|
|
@ -202,46 +145,19 @@ impl SizedNode for PlaceholderNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_workspace(self: &Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
let slf = self.clone();
|
||||
self.toplevel.state.run_toplevel.schedule(move || {
|
||||
slf.tl_destroy();
|
||||
});
|
||||
}
|
||||
|
||||
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 tl_set_visible(&self, visible: bool) {
|
||||
self.toplevel.visible.set(visible);
|
||||
}
|
||||
|
||||
fn client(&self) -> Option<Rc<Client>> {
|
||||
self.client.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedToplevelNode for PlaceholderNode {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
&self.toplevel
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: &Rc<Self>, _fullscreen: bool) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
false
|
||||
fn tl_destroy(&self) {
|
||||
self.toplevel.destroy_node(self);
|
||||
self.destroyed.set(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
src/tree/stacked.rs
Normal file
11
src/tree/stacked.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use {crate::tree::Node, std::rc::Rc};
|
||||
|
||||
pub trait StackedNode: Node {
|
||||
fn stacked_as_node(&self) -> &dyn Node;
|
||||
fn stacked_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn stacked_into_dyn(self: Rc<Self>) -> Rc<dyn StackedNode>;
|
||||
|
||||
fn stacked_absolute_position_constrains_input(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +1,193 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::{wl_seat::SeatId, wl_surface::WlSurface},
|
||||
tree::{Node, SizedNode, WorkspaceNode},
|
||||
utils::{numcell::NumCell, smallmap::SmallMap},
|
||||
client::Client,
|
||||
ifs::wl_seat::{collect_kb_foci, NodeSeatState, SeatId},
|
||||
rect::Rect,
|
||||
state::State,
|
||||
tree::{ContainingNode, Node, OutputNode, PlaceholderNode, WorkspaceNode},
|
||||
utils::{clonecell::CloneCell, numcell::NumCell, smallmap::SmallMap},
|
||||
},
|
||||
jay_config::Direction,
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub trait SizedToplevelNode: SizedNode {
|
||||
fn data(&self) -> &ToplevelData;
|
||||
fn accepts_keyboard_focus(&self) -> bool;
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>>;
|
||||
fn set_active(&self, active: bool);
|
||||
fn activate(&self);
|
||||
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool);
|
||||
fn fullscreen(&self) -> bool;
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
tree_id!(ToplevelNodeId);
|
||||
pub trait ToplevelNode {
|
||||
fn data(&self) -> &ToplevelData;
|
||||
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) -> Option<Rc<WlSurface>>;
|
||||
fn set_active(&self, active: bool);
|
||||
fn activate(&self);
|
||||
fn set_fullscreen(self: Rc<Self>, fullscreen: bool);
|
||||
fn fullscreen(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T: SizedToplevelNode> ToplevelNode for T {
|
||||
fn data(&self) -> &ToplevelData {
|
||||
<Self as SizedToplevelNode>::data(self)
|
||||
pub trait ToplevelNode: Node {
|
||||
fn tl_as_node(&self) -> &dyn Node;
|
||||
fn tl_into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn tl_into_dyn(self: Rc<Self>) -> Rc<dyn ToplevelNode>;
|
||||
|
||||
fn tl_data(&self) -> &ToplevelData;
|
||||
fn tl_default_focus_child(&self) -> Option<Rc<dyn Node>>;
|
||||
|
||||
fn tl_accepts_keyboard_focus(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
<Self as SizedToplevelNode>::as_node(self)
|
||||
fn tl_set_active(&self, active: bool) {
|
||||
let _ = active;
|
||||
}
|
||||
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node> {
|
||||
<Self as SizedToplevelNode>::into_node(self)
|
||||
fn tl_on_activate(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn accepts_keyboard_focus(&self) -> bool {
|
||||
<Self as SizedToplevelNode>::accepts_keyboard_focus(self)
|
||||
fn tl_surface_active_changed(&self, active: bool) {
|
||||
if active {
|
||||
if self.tl_data().active_children.fetch_add(1) == 0 {
|
||||
self.tl_set_active(true);
|
||||
}
|
||||
} else {
|
||||
if self.tl_data().active_children.fetch_sub(1) == 1 {
|
||||
self.tl_set_active(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_surface(&self) -> Option<Rc<WlSurface>> {
|
||||
<Self as SizedToplevelNode>::default_surface(self)
|
||||
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 set_active(&self, active: bool) {
|
||||
<Self as SizedToplevelNode>::set_active(self, active)
|
||||
fn tl_set_fullscreen(self: Rc<Self>, fullscreen: bool) {
|
||||
let data = self.tl_data();
|
||||
if fullscreen {
|
||||
if let Some(ws) = data.workspace.get() {
|
||||
data.set_fullscreen2(
|
||||
&data.state,
|
||||
self.clone().tl_into_dyn(),
|
||||
&ws,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
data.unset_fullscreen(&data.state, self.clone().tl_into_dyn());
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
<Self as SizedToplevelNode>::activate(self)
|
||||
fn tl_title(&self) -> String {
|
||||
self.tl_data().title.borrow_mut().clone()
|
||||
}
|
||||
|
||||
fn set_fullscreen(self: Rc<Self>, fullscreen: bool) {
|
||||
<Self as SizedToplevelNode>::set_fullscreen(&self, fullscreen)
|
||||
fn tl_title_changed(&self) {
|
||||
let data = self.tl_data();
|
||||
let title = data.title.borrow_mut();
|
||||
if let Some(parent) = data.parent.get() {
|
||||
parent.node_child_title_changed(self.tl_as_node(), &title);
|
||||
}
|
||||
if let Some(data) = data.fullscrceen_data.borrow_mut().deref() {
|
||||
*data.placeholder.tl_data().title.borrow_mut() = title.clone();
|
||||
data.placeholder.tl_title_changed();
|
||||
}
|
||||
}
|
||||
|
||||
fn fullscreen(&self) -> bool {
|
||||
<Self as SizedToplevelNode>::fullscreen(self)
|
||||
fn tl_set_parent(&self, parent: Rc<dyn ContainingNode>) {
|
||||
let data = self.tl_data();
|
||||
data.parent.set(Some(parent.clone()));
|
||||
data.is_floating.set(parent.node_is_float());
|
||||
self.tl_notify_parent();
|
||||
self.tl_after_parent_set(parent);
|
||||
}
|
||||
|
||||
fn tl_after_parent_set(&self, parent: Rc<dyn ContainingNode>) {
|
||||
let _ = parent;
|
||||
}
|
||||
|
||||
fn tl_notify_parent(&self) {
|
||||
let data = self.tl_data();
|
||||
let parent = match data.parent.get() {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
let node = self.tl_as_node();
|
||||
let pos = data.pos.get();
|
||||
let depth = if data.active.get() {
|
||||
1
|
||||
} else if data.active_children.get() > 0 {
|
||||
2
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if depth > 0 {
|
||||
parent.clone().node_child_active_changed(node, true, depth);
|
||||
}
|
||||
parent.node_child_size_changed(node, pos.width(), pos.height());
|
||||
parent
|
||||
.clone()
|
||||
.node_child_title_changed(node, data.title.borrow_mut().deref());
|
||||
}
|
||||
|
||||
fn tl_set_workspace(self: Rc<Self>, ws: &Rc<WorkspaceNode>) {
|
||||
let data = self.tl_data();
|
||||
data.workspace.set(Some(ws.clone()));
|
||||
}
|
||||
|
||||
fn tl_change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let _ = rect;
|
||||
}
|
||||
|
||||
fn tl_close(self: Rc<Self>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn tl_set_visible(&self, visible: bool);
|
||||
fn tl_destroy(&self);
|
||||
|
||||
fn tl_last_active_child(self: Rc<Self>) -> Rc<dyn ToplevelNode> {
|
||||
self.tl_into_dyn()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FullscreenedData {
|
||||
pub placeholder: Rc<PlaceholderNode>,
|
||||
pub workspace: Rc<WorkspaceNode>,
|
||||
}
|
||||
|
||||
pub struct ToplevelData {
|
||||
pub active_surfaces: NumCell<u32>,
|
||||
pub focus_surface: SmallMap<SeatId, Rc<WlSurface>, 1>,
|
||||
pub active: Cell<bool>,
|
||||
pub client: Option<Rc<Client>>,
|
||||
pub state: Rc<State>,
|
||||
pub active_children: NumCell<u32>,
|
||||
pub focus_node: SmallMap<SeatId, Rc<dyn Node>, 1>,
|
||||
pub visible: Cell<bool>,
|
||||
pub is_floating: Cell<bool>,
|
||||
pub float_width: Cell<i32>,
|
||||
pub float_height: Cell<i32>,
|
||||
pub is_fullscreen: Cell<bool>,
|
||||
pub fullscrceen_data: RefCell<Option<FullscreenedData>>,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub title: RefCell<String>,
|
||||
pub parent: CloneCell<Option<Rc<dyn ContainingNode>>>,
|
||||
pub pos: Cell<Rect>,
|
||||
pub seat_state: NodeSeatState,
|
||||
}
|
||||
|
||||
impl ToplevelData {
|
||||
pub fn clear(&self) {
|
||||
self.focus_surface.clear();
|
||||
pub fn new(state: &Rc<State>, title: String, client: Option<Rc<Client>>) -> Self {
|
||||
Self {
|
||||
active: Cell::new(false),
|
||||
client,
|
||||
state: state.clone(),
|
||||
active_children: Default::default(),
|
||||
focus_node: Default::default(),
|
||||
visible: Cell::new(false),
|
||||
is_floating: Default::default(),
|
||||
float_width: Default::default(),
|
||||
float_height: Default::default(),
|
||||
is_fullscreen: Default::default(),
|
||||
fullscrceen_data: Default::default(),
|
||||
workspace: Default::default(),
|
||||
title: RefCell::new(title),
|
||||
parent: Default::default(),
|
||||
pos: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn float_size(&self, ws: &WorkspaceNode) -> (i32, i32) {
|
||||
|
|
@ -102,29 +202,127 @@ impl ToplevelData {
|
|||
}
|
||||
(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> dyn ToplevelNode + 'a {
|
||||
pub fn surface_active_changed(&self, active: bool) {
|
||||
if active {
|
||||
if self.data().active_surfaces.fetch_add(1) == 0 {
|
||||
self.set_active(true);
|
||||
}
|
||||
} else {
|
||||
if self.data().active_surfaces.fetch_sub(1) == 1 {
|
||||
self.set_active(false);
|
||||
pub fn destroy_node(&self, node: &dyn Node) {
|
||||
if let Some(fd) = self.fullscrceen_data.borrow_mut().take() {
|
||||
fd.placeholder.tl_destroy();
|
||||
}
|
||||
if let Some(parent) = self.parent.take() {
|
||||
parent.cnode_remove_child(node);
|
||||
}
|
||||
self.workspace.take();
|
||||
self.seat_state.destroy_node(node);
|
||||
self.focus_node.clear();
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(
|
||||
&self,
|
||||
state: &Rc<State>,
|
||||
node: Rc<dyn ToplevelNode>,
|
||||
output: &Rc<OutputNode>,
|
||||
) {
|
||||
self.set_fullscreen2(state, node, &output.ensure_workspace());
|
||||
}
|
||||
|
||||
pub fn set_fullscreen2(
|
||||
&self,
|
||||
state: &Rc<State>,
|
||||
node: Rc<dyn ToplevelNode>,
|
||||
ws: &Rc<WorkspaceNode>,
|
||||
) {
|
||||
if ws.fullscreen.get().is_some() {
|
||||
log::info!("Cannot fullscreen a node on a workspace that already has a fullscreen node attached");
|
||||
return;
|
||||
}
|
||||
if node.node_is_placeholder() {
|
||||
log::info!("Cannot fullscreen a placeholder node");
|
||||
return;
|
||||
}
|
||||
let mut data = self.fullscrceen_data.borrow_mut();
|
||||
if data.is_some() {
|
||||
log::info!("Cannot fullscreen a node that is already fullscreen");
|
||||
return;
|
||||
}
|
||||
let parent = match node.tl_data().parent.get() {
|
||||
None => {
|
||||
log::warn!("Cannot fullscreen a node without a parent");
|
||||
return;
|
||||
}
|
||||
Some(p) => p,
|
||||
};
|
||||
let placeholder = Rc::new(PlaceholderNode::new_for(state, node.clone()));
|
||||
parent.cnode_replace_child(node.tl_as_node(), placeholder.clone());
|
||||
let mut kb_foci = Default::default();
|
||||
if let Some(container) = ws.container.get() {
|
||||
kb_foci = collect_kb_foci(container.clone());
|
||||
container.tl_set_visible(false);
|
||||
}
|
||||
*data = Some(FullscreenedData {
|
||||
placeholder,
|
||||
workspace: ws.clone(),
|
||||
});
|
||||
self.is_fullscreen.set(true);
|
||||
ws.fullscreen.set(Some(node.clone()));
|
||||
node.tl_set_parent(ws.clone());
|
||||
node.clone().tl_set_workspace(&ws);
|
||||
node.clone()
|
||||
.tl_change_extents(&ws.output.get().global.pos.get());
|
||||
for seat in kb_foci {
|
||||
node.clone()
|
||||
.tl_into_node()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: SeatId) -> Option<Rc<WlSurface>> {
|
||||
self.data()
|
||||
.focus_surface
|
||||
.get(&seat)
|
||||
.or_else(|| self.default_surface())
|
||||
pub fn unset_fullscreen(&self, state: &Rc<State>, node: Rc<dyn ToplevelNode>) {
|
||||
if !self.is_fullscreen.get() {
|
||||
log::warn!("Cannot unset fullscreen on a node that is not fullscreen");
|
||||
return;
|
||||
}
|
||||
let fd = match self.fullscrceen_data.borrow_mut().take() {
|
||||
Some(fd) => fd,
|
||||
_ => {
|
||||
log::error!("is_fullscreen = true but data is None");
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.is_fullscreen.set(false);
|
||||
match fd.workspace.fullscreen.get() {
|
||||
None => {
|
||||
log::error!("Node is supposed to be fullscreened on a workspace but workspace has not fullscreen node.");
|
||||
return;
|
||||
}
|
||||
Some(f) if f.tl_as_node().node_id() != node.tl_as_node().node_id() => {
|
||||
log::error!("Node is supposed to be fullscreened on a workspace but the workspace has a different node attached.");
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
fd.workspace.fullscreen.take();
|
||||
if let Some(container) = fd.workspace.container.get() {
|
||||
container.tl_set_visible(node.tl_as_node().node_visible());
|
||||
}
|
||||
if fd.placeholder.is_destroyed() {
|
||||
state.map_tiled(node);
|
||||
return;
|
||||
}
|
||||
let parent = fd.placeholder.tl_data().parent.get().unwrap();
|
||||
parent.cnode_replace_child(fd.placeholder.deref(), node.clone());
|
||||
if node.tl_as_node().node_visible() {
|
||||
let kb_foci = collect_kb_foci(fd.placeholder.clone());
|
||||
for seat in kb_foci {
|
||||
node.clone()
|
||||
.tl_into_node()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
fd.placeholder
|
||||
.node_seat_state()
|
||||
.destroy_node(fd.placeholder.deref());
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
self.as_node().node_parent()
|
||||
pub fn set_visible(&self, node: &dyn Node, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
self.seat_state.set_visible(node, visible)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use {
|
|||
rect::Rect,
|
||||
render::Renderer,
|
||||
tree::{
|
||||
container::ContainerNode, walker::NodeVisitor, FindTreeResult, FoundNode,
|
||||
FullscreenNode, Node, NodeId, OutputNode, SizedNode,
|
||||
container::ContainerNode, walker::NodeVisitor, ContainingNode, FindTreeResult,
|
||||
FoundNode, Node, NodeId, OutputNode, StackedNode, ToplevelNode,
|
||||
},
|
||||
utils::{
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -24,101 +24,81 @@ pub struct WorkspaceNode {
|
|||
pub output: CloneCell<Rc<OutputNode>>,
|
||||
pub position: Cell<Rect>,
|
||||
pub container: CloneCell<Option<Rc<ContainerNode>>>,
|
||||
pub stacked: LinkedList<Rc<dyn Node>>,
|
||||
pub stacked: LinkedList<Rc<dyn StackedNode>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub name: String,
|
||||
pub output_link: Cell<Option<LinkedNode<Rc<WorkspaceNode>>>>,
|
||||
pub visible: Cell<bool>,
|
||||
pub fullscreen: CloneCell<Option<Rc<dyn FullscreenNode>>>,
|
||||
pub fullscreen: CloneCell<Option<Rc<dyn ToplevelNode>>>,
|
||||
}
|
||||
|
||||
impl WorkspaceNode {
|
||||
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
|
||||
let pos = self.position.get();
|
||||
container.change_extents(&pos);
|
||||
container.set_workspace(self);
|
||||
container.set_visible(self.visible.get());
|
||||
container.clone().tl_change_extents(&pos);
|
||||
container.clone().tl_set_workspace(self);
|
||||
container.tl_set_parent(self.clone());
|
||||
container.tl_set_visible(self.visible.get() && self.fullscreen.get().is_none());
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
|
||||
pub fn change_extents(&self, rect: &Rect) {
|
||||
self.position.set(*rect);
|
||||
if let Some(c) = self.container.get() {
|
||||
c.tl_change_extents(rect);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.tl_set_visible(visible);
|
||||
} else if let Some(container) = self.container.get() {
|
||||
container.tl_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
}
|
||||
|
||||
impl SizedNode for WorkspaceNode {
|
||||
fn id(&self) -> NodeId {
|
||||
impl Node for WorkspaceNode {
|
||||
fn node_id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
||||
fn seat_state(&self) -> &NodeSeatState {
|
||||
fn node_seat_state(&self) -> &NodeSeatState {
|
||||
&self.seat_state
|
||||
}
|
||||
|
||||
fn destroy_node(&self, detach: bool) {
|
||||
if detach {
|
||||
self.output.get().node_remove_child(self);
|
||||
}
|
||||
self.output_link.set(None);
|
||||
if let Some(fs) = self.fullscreen.take() {
|
||||
fs.into_node().node_destroy(false);
|
||||
}
|
||||
if let Some(container) = self.container.take() {
|
||||
container.node_destroy(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
fn node_visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_workspace(&self);
|
||||
}
|
||||
|
||||
fn visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_workspace(self);
|
||||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
if let Some(c) = self.container.get() {
|
||||
visitor.visit_container(&c);
|
||||
}
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.into_node().node_visit(visitor);
|
||||
fs.tl_into_node().node_visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
fn visible(&self) -> bool {
|
||||
fn node_visible(&self) -> bool {
|
||||
self.visible.get()
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<Rc<dyn Node>> {
|
||||
Some(self.output.get())
|
||||
}
|
||||
|
||||
fn last_active_child(self: &Rc<Self>) -> Rc<dyn Node> {
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
return fs.into_node().node_last_active_child();
|
||||
}
|
||||
if let Some(c) = self.container.get() {
|
||||
return c.last_active_child();
|
||||
}
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.as_node().node_set_visible(visible);
|
||||
} else if let Some(container) = self.container.get() {
|
||||
container.node_set_visible(visible);
|
||||
}
|
||||
self.seat_state.set_visible(self, visible);
|
||||
}
|
||||
|
||||
fn do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.into_node().node_do_focus(seat, direction);
|
||||
} else if let Some(container) = self.container.get() {
|
||||
container.do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
fn node_absolute_position(&self) -> Rect {
|
||||
self.position.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
fs.tl_into_node().node_do_focus(seat, direction);
|
||||
} else if let Some(container) = self.container.get() {
|
||||
container.node_do_focus(seat, direction);
|
||||
}
|
||||
}
|
||||
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(n) = self.container.get() {
|
||||
tree.push(FoundNode {
|
||||
node: n.clone(),
|
||||
|
|
@ -130,7 +110,48 @@ impl SizedNode for WorkspaceNode {
|
|||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child2(self: &Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
|
||||
fn node_render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_workspace(self, x, y);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn node_into_workspace(self: Rc<Self>) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn node_into_containing_node(self: Rc<Self>) -> Option<Rc<dyn ContainingNode>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn node_is_workspace(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl ContainingNode for WorkspaceNode {
|
||||
containing_node_impl!();
|
||||
|
||||
fn cnode_replace_child(self: Rc<Self>, old: &dyn Node, new: Rc<dyn ToplevelNode>) {
|
||||
if let Some(container) = self.container.get() {
|
||||
if container.node_id() == old.node_id() {
|
||||
let new = match new.tl_into_node().node_into_container() {
|
||||
Some(c) => c,
|
||||
_ => {
|
||||
log::error!("cnode_replace_child called with non-container new");
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.set_container(&new);
|
||||
return;
|
||||
}
|
||||
}
|
||||
log::error!("Trying to replace child that's not a child");
|
||||
}
|
||||
|
||||
fn cnode_remove_child2(self: Rc<Self>, child: &dyn Node, _preserve_focus: bool) {
|
||||
if let Some(container) = self.container.get() {
|
||||
if container.node_id() == child.node_id() {
|
||||
self.container.set(None);
|
||||
|
|
@ -138,7 +159,7 @@ impl SizedNode for WorkspaceNode {
|
|||
}
|
||||
}
|
||||
if let Some(fs) = self.fullscreen.get() {
|
||||
if fs.as_node().node_id() == child.node_id() {
|
||||
if fs.tl_as_node().node_id() == child.node_id() {
|
||||
self.fullscreen.set(None);
|
||||
return;
|
||||
}
|
||||
|
|
@ -146,30 +167,7 @@ impl SizedNode for WorkspaceNode {
|
|||
log::error!("Trying to remove child that's not a child");
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
seat.set_known_cursor(KnownCursor::Default);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_workspace(self, x, y);
|
||||
}
|
||||
|
||||
fn into_workspace(self: &Rc<Self>) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.clone())
|
||||
}
|
||||
|
||||
fn accepts_child(&self, node: &dyn Node) -> bool {
|
||||
fn cnode_accepts_child(&self, node: &dyn Node) -> bool {
|
||||
node.node_is_container()
|
||||
}
|
||||
|
||||
fn is_workspace(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn change_extents(self: &Rc<Self>, rect: &Rect) {
|
||||
self.position.set(*rect);
|
||||
if let Some(c) = self.container.get() {
|
||||
c.node_change_extents(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue