1
0
Fork 0
forked from wry/wry

autocommit 2022-01-30 22:41:40 CET

This commit is contained in:
Julian Orth 2022-01-30 22:41:40 +01:00
parent f577f5feef
commit 865d5f295d
26 changed files with 1085 additions and 676 deletions

View file

@ -1,11 +1,11 @@
use std::ops::Deref;
use crate::rect::Rect;
use crate::render::Renderer;
use crate::tree::container::ContainerNode;
use crate::tree::{FoundNode, Node, NodeId, OutputNode, StackedNode};
use crate::tree::{AbsoluteNode, FindTreeResult, FoundNode, Node, NodeId, OutputNode};
use crate::utils::clonecell::CloneCell;
use crate::utils::linkedlist::LinkedList;
use std::rc::Rc;
use crate::rect::Rect;
use crate::ifs::wl_seat::NodeSeatState;
tree_id!(WorkspaceNodeId);
@ -13,15 +13,15 @@ pub struct WorkspaceNode {
pub id: WorkspaceNodeId,
pub output: CloneCell<Rc<OutputNode>>,
pub container: CloneCell<Option<Rc<ContainerNode>>>,
pub stacked: LinkedList<StackedNode>,
pub stacked: LinkedList<Rc<dyn AbsoluteNode>>,
pub seat_state: NodeSeatState,
}
impl WorkspaceNode {
pub fn set_container(&self, container: &Rc<ContainerNode>) {
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
let output = self.output.get().position.get();
container
.clone()
.change_extents(&output);
container.clone().change_extents(&output);
container.clone().set_workspace(self);
self.container.set(Some(container.clone()));
}
}
@ -31,48 +31,40 @@ impl Node for WorkspaceNode {
self.id.into()
}
fn clear(&self) {
if let Some(child) = self.container.take() {
child.clear();
}
fn seat_state(&self) -> &NodeSeatState {
&self.seat_state
}
fn find_child_at(&self, x: i32, y: i32) -> Option<FoundNode> {
for stacked in self.stacked.rev_iter() {
let (pos, node) = match stacked.deref() {
StackedNode::Float(f) => (f.position.get(), &**f as &dyn Node),
StackedNode::Popup(p) => (p.xdg.absolute_desired_extents.get(), &**p as &dyn Node),
};
if pos.contains(x, y) {
let (x, y) = pos.translate(x, y);
if let Some(n) = node.find_child_at(x, y) {
return Some(n);
}
}
fn destroy_node(&self, detach: bool) {
if detach {
self.output.get().remove_child(self);
}
match self.container.get() {
Some(node) => Some(FoundNode {
node,
if let Some(container) = self.container.take() {
container.destroy_node(false);
}
self.seat_state.destroy_node(self);
}
fn 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(),
x,
y,
contained: true,
}),
_ => None,
});
n.find_tree_at(x, y, tree);
}
}
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
renderer.render_workspace(self, x, y);
}
fn get_workspace(self: Rc<Self>) -> Option<Rc<WorkspaceNode>> {
Some(self)
FindTreeResult::AcceptsInput
}
fn remove_child(&self, _child: &dyn Node) {
self.container.set(None);
}
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
renderer.render_workspace(self, x, y);
}
fn change_extents(self: Rc<Self>, rect: &Rect) {
if let Some(c) = self.container.get() {
c.change_extents(rect);