autocommit 2022-01-29 23:08:25 CET
This commit is contained in:
parent
11d3604de4
commit
f577f5feef
18 changed files with 484 additions and 173 deletions
|
|
@ -35,6 +35,8 @@ pub struct ContainerNode {
|
|||
pub mono_child: CloneCell<Option<NodeRef<ContainerChild>>>,
|
||||
pub mono_body: Cell<Rect>,
|
||||
pub mono_content: Cell<Rect>,
|
||||
pub abs_x1: Cell<i32>,
|
||||
pub abs_y1: Cell<i32>,
|
||||
pub width: Cell<i32>,
|
||||
pub height: Cell<i32>,
|
||||
pub content_width: Cell<i32>,
|
||||
|
|
@ -90,6 +92,8 @@ impl ContainerNode {
|
|||
mono_child: CloneCell::new(None),
|
||||
mono_body: Cell::new(Default::default()),
|
||||
mono_content: Cell::new(Default::default()),
|
||||
abs_x1: Cell::new(0),
|
||||
abs_y1: Cell::new(0),
|
||||
width: Cell::new(0),
|
||||
height: Cell::new(0),
|
||||
content_width: Cell::new(0),
|
||||
|
|
@ -225,8 +229,8 @@ impl ContainerNode {
|
|||
}
|
||||
}
|
||||
for child in self.children.iter() {
|
||||
let body = child.body.get();
|
||||
child.node.clone().change_size(body.width(), body.height());
|
||||
let body = child.body.get().move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
child.node.clone().change_extents(&body);
|
||||
child.position_content();
|
||||
}
|
||||
}
|
||||
|
|
@ -347,10 +351,20 @@ impl Node for ContainerNode {
|
|||
self.parent.get().get_workspace()
|
||||
}
|
||||
|
||||
fn change_size(self: Rc<Self>, width: i32, height: i32) {
|
||||
self.width.set(width);
|
||||
self.height.set(height);
|
||||
self.update_content_size();
|
||||
self.apply_factors(1.0);
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
self.abs_x1.set(rect.x1());
|
||||
self.abs_y1.set(rect.y1());
|
||||
let mut size_changed = false;
|
||||
size_changed |= self.width.replace(rect.width()) != rect.width();
|
||||
size_changed |= self.height.replace(rect.height()) != rect.height();
|
||||
if size_changed {
|
||||
self.update_content_size();
|
||||
self.apply_factors(1.0);
|
||||
} else {
|
||||
for child in self.children.iter() {
|
||||
let body = child.body.get().move_(self.abs_x1.get(), self.abs_y1.get());
|
||||
child.node.clone().change_extents(&body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use std::cell::{Cell, RefCell};
|
|||
use std::fmt::Display;
|
||||
use std::rc::Rc;
|
||||
pub use workspace::*;
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
|
||||
|
||||
mod container;
|
||||
mod workspace;
|
||||
|
|
@ -129,9 +130,8 @@ pub trait Node {
|
|||
None
|
||||
}
|
||||
|
||||
fn change_size(self: Rc<Self>, width: i32, height: i32) {
|
||||
let _ = width;
|
||||
let _ = height;
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let _ = rect;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,10 +144,15 @@ pub struct FoundNode {
|
|||
|
||||
tree_id!(ToplevelNodeId);
|
||||
|
||||
pub enum StackedNode {
|
||||
Float(Rc<FloatNode>),
|
||||
Popup(Rc<XdgPopup>),
|
||||
}
|
||||
|
||||
pub struct DisplayNode {
|
||||
pub id: NodeId,
|
||||
pub outputs: CopyHashMap<OutputId, Rc<OutputNode>>,
|
||||
pub floaters: LinkedList<Rc<FloatNode>>,
|
||||
pub stacked: LinkedList<StackedNode>,
|
||||
}
|
||||
|
||||
impl DisplayNode {
|
||||
|
|
@ -155,7 +160,7 @@ impl DisplayNode {
|
|||
Self {
|
||||
id,
|
||||
outputs: Default::default(),
|
||||
floaters: Default::default(),
|
||||
stacked: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -171,8 +176,11 @@ impl Node for DisplayNode {
|
|||
output.clear();
|
||||
}
|
||||
outputs.clear();
|
||||
for floater in self.floaters.iter() {
|
||||
floater.clear();
|
||||
for floater in self.stacked.iter() {
|
||||
match &*floater {
|
||||
StackedNode::Float(f) => f.clear(),
|
||||
StackedNode::Popup(p) => p.clear(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,11 +245,10 @@ impl Node for OutputNode {
|
|||
self.workspace.set(None);
|
||||
}
|
||||
|
||||
fn change_size(self: Rc<Self>, width: i32, height: i32) {
|
||||
self.position
|
||||
.set(Rect::new_sized(0, 0, width, height).unwrap());
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
self.position.set(*rect);
|
||||
if let Some(c) = self.workspace.get() {
|
||||
c.change_size(width, height);
|
||||
c.change_extents(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -252,8 +259,8 @@ pub struct FloatNode {
|
|||
pub visible: Cell<bool>,
|
||||
pub position: Cell<Rect>,
|
||||
pub display: Rc<DisplayNode>,
|
||||
pub display_link: Cell<Option<LinkedNode<Rc<FloatNode>>>>,
|
||||
pub workspace_link: Cell<Option<LinkedNode<Rc<FloatNode>>>>,
|
||||
pub display_link: Cell<Option<LinkedNode<StackedNode>>>,
|
||||
pub workspace_link: Cell<Option<LinkedNode<StackedNode>>>,
|
||||
pub workspace: CloneCell<Rc<WorkspaceNode>>,
|
||||
pub child: CloneCell<Option<Rc<dyn Node>>>,
|
||||
}
|
||||
|
|
@ -298,4 +305,10 @@ impl Node for FloatNode {
|
|||
self.position
|
||||
.set(Rect::new_sized(pos.x1(), pos.x2(), width, height).unwrap());
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
if let Some(child) = self.child.get() {
|
||||
child.change_extents(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
use std::ops::Deref;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::container::ContainerNode;
|
||||
use crate::tree::{FloatNode, FoundNode, Node, NodeId, OutputNode};
|
||||
use crate::tree::{FoundNode, Node, NodeId, OutputNode, StackedNode};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use std::rc::Rc;
|
||||
use crate::rect::Rect;
|
||||
|
||||
tree_id!(WorkspaceNodeId);
|
||||
|
||||
|
|
@ -11,7 +13,7 @@ pub struct WorkspaceNode {
|
|||
pub id: WorkspaceNodeId,
|
||||
pub output: CloneCell<Rc<OutputNode>>,
|
||||
pub container: CloneCell<Option<Rc<ContainerNode>>>,
|
||||
pub floaters: LinkedList<Rc<FloatNode>>,
|
||||
pub stacked: LinkedList<StackedNode>,
|
||||
}
|
||||
|
||||
impl WorkspaceNode {
|
||||
|
|
@ -19,7 +21,7 @@ impl WorkspaceNode {
|
|||
let output = self.output.get().position.get();
|
||||
container
|
||||
.clone()
|
||||
.change_size(output.width(), output.height());
|
||||
.change_extents(&output);
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +38,18 @@ impl Node for WorkspaceNode {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
match self.container.get() {
|
||||
Some(node) => Some(FoundNode {
|
||||
node,
|
||||
|
|
@ -59,9 +73,9 @@ impl Node for WorkspaceNode {
|
|||
self.container.set(None);
|
||||
}
|
||||
|
||||
fn change_size(self: Rc<Self>, width: i32, height: i32) {
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
if let Some(c) = self.container.get() {
|
||||
c.change_size(width, height);
|
||||
c.change_extents(rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue