autocommit 2022-04-02 00:31:30 CEST
This commit is contained in:
parent
2dd433aa04
commit
6ad6d83b7e
34 changed files with 446 additions and 161 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::backend::KeyState;
|
||||
use crate::backend::{KeyState};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT};
|
||||
|
|
@ -693,6 +693,10 @@ impl Node for ContainerNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
let parent = self.parent.get();
|
||||
if parent.id() == other {
|
||||
|
|
@ -1055,9 +1059,23 @@ impl Node for ContainerNode {
|
|||
|
||||
fn remove_child(self: Rc<Self>, child: &dyn Node) {
|
||||
let node = match self.child_nodes.borrow_mut().remove(&child.id()) {
|
||||
Some(c) => c.to_ref(),
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
};
|
||||
let mut mono_child = None;
|
||||
if let Some(mono) = self.mono_child.get() {
|
||||
if mono.node.id() == child.id() {
|
||||
self.mono_child.take();
|
||||
mono_child = node.next();
|
||||
if mono_child.is_none() {
|
||||
mono_child = node.prev();
|
||||
}
|
||||
}
|
||||
}
|
||||
let node = {
|
||||
let node = node;
|
||||
node.to_ref()
|
||||
};
|
||||
let num_children = self.num_children.fetch_sub(1) - 1;
|
||||
if num_children == 0 {
|
||||
self.seats.borrow_mut().clear();
|
||||
|
|
@ -1080,6 +1098,9 @@ impl Node for ContainerNode {
|
|||
sum += factor;
|
||||
}
|
||||
}
|
||||
if mono_child.is_some() {
|
||||
self.mono_child.set(mono_child);
|
||||
}
|
||||
self.sum_factors.set(sum);
|
||||
self.update_title();
|
||||
self.schedule_layout();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::backend::KeyState;
|
||||
use crate::backend::{KeyState};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT};
|
||||
|
|
@ -343,6 +343,10 @@ impl Node for FloatNode {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
Some(self.workspace.get())
|
||||
}
|
||||
|
||||
fn child_title_changed(self: Rc<Self>, _child: &dyn Node, title: &str) {
|
||||
let mut t = self.title.borrow_mut();
|
||||
if t.deref() != title {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_output::WlOutputGlobal;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
|
||||
|
|
@ -16,14 +17,13 @@ use std::cell::{Cell, RefCell};
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::{Deref, Sub};
|
||||
use std::rc::Rc;
|
||||
use crate::fixed::Fixed;
|
||||
|
||||
tree_id!(OutputNodeId);
|
||||
pub struct OutputNode {
|
||||
pub id: OutputNodeId,
|
||||
pub position: Cell<Rect>,
|
||||
pub global: Rc<WlOutputGlobal>,
|
||||
pub workspaces: RefCell<Vec<Rc<WorkspaceNode>>>,
|
||||
pub workspaces: LinkedList<Rc<WorkspaceNode>>,
|
||||
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub layers: [LinkedList<Rc<ZwlrLayerSurfaceV1>>; 4],
|
||||
|
|
@ -37,12 +37,11 @@ impl OutputNode {
|
|||
let mut rd = self.render_data.borrow_mut();
|
||||
rd.titles.clear();
|
||||
rd.inactive_workspaces.clear();
|
||||
let workspaces = self.workspaces.borrow_mut();
|
||||
let mut pos = 0;
|
||||
let font = self.state.theme.font.borrow_mut();
|
||||
let th = self.state.theme.title_height.get();
|
||||
let active_id = self.workspace.get().map(|w| w.id);
|
||||
for ws in workspaces.deref() {
|
||||
for ws in self.workspaces.iter() {
|
||||
let mut title_width = th;
|
||||
'create_texture: {
|
||||
if let Some(ctx) = self.state.render_ctx.get() {
|
||||
|
|
@ -78,6 +77,23 @@ impl OutputNode {
|
|||
pos += title_width;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show_workspace(&self, ws: &Rc<WorkspaceNode>) {
|
||||
self.workspace.set(Some(ws.clone()));
|
||||
ws.clone().change_extents(&self.workspace_rect());
|
||||
}
|
||||
|
||||
fn workspace_rect(&self) -> Rect {
|
||||
let rect = self.position.get();
|
||||
let th = self.state.theme.title_height.get();
|
||||
Rect::new_sized(
|
||||
rect.x1(),
|
||||
rect.y1() + th,
|
||||
rect.width(),
|
||||
rect.height().sub(th).max(0),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OutputTitle {
|
||||
|
|
@ -100,14 +116,6 @@ impl Debug for OutputNode {
|
|||
}
|
||||
|
||||
impl Node for OutputNode {
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_output(&self)
|
||||
}
|
||||
|
||||
fn leave(&self, seat: &WlSeatGlobal) {
|
||||
seat.leave_output();
|
||||
}
|
||||
|
||||
fn id(&self) -> NodeId {
|
||||
self.id.into()
|
||||
}
|
||||
|
|
@ -120,8 +128,9 @@ impl Node for OutputNode {
|
|||
if detach {
|
||||
self.state.root.clone().remove_child(self);
|
||||
}
|
||||
let mut workspaces = self.workspaces.borrow_mut();
|
||||
for workspace in workspaces.drain(..) {
|
||||
self.workspace.set(None);
|
||||
let workspaces: Vec<_> = self.workspaces.iter().map(|e| e.deref().clone()).collect();
|
||||
for workspace in workspaces {
|
||||
workspace.destroy_node(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
|
|
@ -132,9 +141,8 @@ impl Node for OutputNode {
|
|||
}
|
||||
|
||||
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
|
||||
let ws = self.workspaces.borrow_mut();
|
||||
for ws in ws.deref() {
|
||||
visitor.visit_workspace(ws);
|
||||
for ws in self.workspaces.iter() {
|
||||
visitor.visit_workspace(ws.deref());
|
||||
}
|
||||
for layers in &self.layers {
|
||||
for surface in layers.iter() {
|
||||
|
|
@ -147,20 +155,32 @@ impl Node for OutputNode {
|
|||
self.position.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
tree.push(FoundNode {
|
||||
node: ws.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
ws.find_tree_at(x, y, tree);
|
||||
fn find_tree_at(&self, x: i32, mut y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let th = self.state.theme.title_height.get();
|
||||
if y > th {
|
||||
y -= th;
|
||||
if let Some(ws) = self.workspace.get() {
|
||||
tree.push(FoundNode {
|
||||
node: ws.clone(),
|
||||
x,
|
||||
y,
|
||||
});
|
||||
ws.find_tree_at(x, y, tree);
|
||||
}
|
||||
}
|
||||
FindTreeResult::AcceptsInput
|
||||
}
|
||||
|
||||
fn remove_child(self: Rc<Self>, _child: &dyn Node) {
|
||||
self.workspace.set(None);
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn leave(&self, seat: &WlSeatGlobal) {
|
||||
seat.leave_output();
|
||||
}
|
||||
|
||||
fn pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_output(&self)
|
||||
}
|
||||
|
||||
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
|
|
@ -180,17 +200,9 @@ impl Node for OutputNode {
|
|||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, rect: &Rect) {
|
||||
let th = self.state.theme.title_height.get();
|
||||
self.position.set(*rect);
|
||||
if let Some(c) = self.workspace.get() {
|
||||
let wrect = Rect::new_sized(
|
||||
rect.x1(),
|
||||
rect.y1() + th,
|
||||
rect.width(),
|
||||
rect.height().sub(th).max(0),
|
||||
)
|
||||
.unwrap();
|
||||
c.change_extents(&wrect);
|
||||
c.change_extents(&self.workspace_rect());
|
||||
}
|
||||
for layer in &self.layers {
|
||||
for surface in layer.iter() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::ifs::wl_seat::SeatId;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::tree::{Node, WorkspaceNode};
|
||||
use crate::tree::{Node};
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
use crate::utils::numcell::NumCell;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
|
|
@ -9,7 +9,6 @@ use std::rc::Rc;
|
|||
pub trait ToplevelNode {
|
||||
fn data(&self) -> &ToplevelData;
|
||||
fn parent(&self) -> Option<Rc<dyn Node>>;
|
||||
fn workspace(&self) -> Option<Rc<WorkspaceNode>>;
|
||||
fn as_node(&self) -> &dyn Node;
|
||||
fn into_node(self: Rc<Self>) -> Rc<dyn Node>;
|
||||
fn accepts_keyboard_focus(&self) -> bool;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ use crate::tree::container::ContainerNode;
|
|||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, OutputNode};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use crate::utils::linkedlist::{LinkedList, LinkedNode};
|
||||
use std::cell::Cell;
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -15,16 +16,18 @@ tree_id!(WorkspaceNodeId);
|
|||
pub struct WorkspaceNode {
|
||||
pub id: WorkspaceNodeId,
|
||||
pub output: CloneCell<Rc<OutputNode>>,
|
||||
pub position: Cell<Rect>,
|
||||
pub container: CloneCell<Option<Rc<ContainerNode>>>,
|
||||
pub stacked: LinkedList<Rc<dyn Node>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub name: String,
|
||||
pub output_link: Cell<Option<LinkedNode<Rc<WorkspaceNode>>>>,
|
||||
}
|
||||
|
||||
impl WorkspaceNode {
|
||||
pub fn set_container(self: &Rc<Self>, container: &Rc<ContainerNode>) {
|
||||
let output = self.output.get().position.get();
|
||||
container.clone().change_extents(&output);
|
||||
let pos = self.position.get();
|
||||
container.clone().change_extents(&pos);
|
||||
container.clone().set_workspace(self);
|
||||
self.container.set(Some(container.clone()));
|
||||
}
|
||||
|
|
@ -43,16 +46,13 @@ impl Node for WorkspaceNode {
|
|||
if detach {
|
||||
self.output.get().remove_child(self);
|
||||
}
|
||||
self.output_link.set(None);
|
||||
if let Some(container) = self.container.take() {
|
||||
container.destroy_node(false);
|
||||
}
|
||||
self.seat_state.destroy_node(self);
|
||||
}
|
||||
|
||||
fn accepts_child(&self, node: &dyn Node) -> bool {
|
||||
node.is_container()
|
||||
}
|
||||
|
||||
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
|
||||
visitor.visit_workspace(&self);
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ impl Node for WorkspaceNode {
|
|||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.output.get().position.get()
|
||||
self.position.get()
|
||||
}
|
||||
|
||||
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
|
|
@ -91,11 +91,16 @@ impl Node for WorkspaceNode {
|
|||
renderer.render_workspace(self, x, y);
|
||||
}
|
||||
|
||||
fn accepts_child(&self, node: &dyn Node) -> bool {
|
||||
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.change_extents(rect);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue