1
0
Fork 0
forked from wry/wry

autocommit 2022-02-24 16:30:11 CET

This commit is contained in:
Julian Orth 2022-02-24 16:30:11 +01:00
parent 666e475032
commit 7d28d30666
39 changed files with 1670 additions and 209 deletions

View file

@ -14,17 +14,18 @@ use crate::NumCell;
pub use container::*;
pub use float::*;
use i4config::Direction;
pub use output::*;
use std::fmt::{Debug, Display};
use std::ops::Deref;
use std::rc::Rc;
pub use workspace::*;
pub use output::*;
mod container;
mod float;
mod output;
pub mod walker;
mod workspace;
mod output;
pub mod toplevel;
pub struct NodeIds {
next: NumCell<u32>,

View file

@ -1,17 +1,17 @@
use std::cell::{Cell, RefCell};
use std::fmt::{Debug, Formatter};
use std::ops::Deref;
use std::rc::Rc;
use crate::{CloneCell, DisplayNode};
use crate::cursor::KnownCursor;
use crate::ifs::wl_output::WlOutputGlobal;
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
use crate::rect::Rect;
use crate::render::Renderer;
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
use crate::tree::walker::NodeVisitor;
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
use crate::utils::linkedlist::LinkedList;
use crate::{CloneCell, DisplayNode};
use std::cell::{Cell, RefCell};
use std::fmt::{Debug, Formatter};
use std::ops::Deref;
use std::rc::Rc;
tree_id!(OutputNodeId);
pub struct OutputNode {

19
src/tree/toplevel.rs Normal file
View file

@ -0,0 +1,19 @@
use std::rc::Rc;
use crate::ifs::wl_seat::WlSeatGlobal;
use crate::ifs::wl_surface::WlSurface;
use crate::tree::Node;
use crate::utils::linkedlist::LinkedNode;
pub trait ToplevelNode: Node {
fn parent(&self) -> Option<Rc<dyn Node>>;
fn focus_surface(&self, seat: &WlSeatGlobal) -> Rc<WlSurface>;
fn set_focus_history_link(&self, seat: &WlSeatGlobal, link: LinkedNode<Rc<dyn ToplevelNode>>);
fn as_node(&self) -> &dyn Node;
fn parent_is_float(&self) -> bool {
if let Some(parent) = self.parent() {
return parent.is_float();
}
false
}
}

View file

@ -1,10 +1,11 @@
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
use crate::ifs::wl_surface::WlSurface;
use crate::tree::{ContainerNode, FloatNode, Node, OutputNode, WorkspaceNode};
use crate::DisplayNode;
use std::rc::Rc;
use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1;
use crate::ifs::wl_surface::xwindow::Xwindow;
pub trait NodeVisitorBase: Sized {
fn visit_surface(&mut self, node: &Rc<WlSurface>) {
@ -42,6 +43,10 @@ pub trait NodeVisitorBase: Sized {
fn visit_layer_surface(&mut self, node: &Rc<ZwlrLayerSurfaceV1>) {
node.visit_children(self);
}
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
node.visit_children(self);
}
}
pub trait NodeVisitor {
@ -54,6 +59,7 @@ pub trait NodeVisitor {
fn visit_float(&mut self, node: &Rc<FloatNode>);
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>);
}
impl<T: NodeVisitorBase> NodeVisitor for T {
@ -92,6 +98,10 @@ impl<T: NodeVisitorBase> NodeVisitor for T {
fn visit_layer_surface(&mut self, node: &Rc<ZwlrLayerSurfaceV1>) {
<T as NodeVisitorBase>::visit_layer_surface(self, node)
}
fn visit_xwindow(&mut self, node: &Rc<Xwindow>) {
<T as NodeVisitorBase>::visit_xwindow(self, node)
}
}
// pub fn visit_containers<F: FnMut(&Rc<ContainerNode>)>(f: F) -> impl NodeVisitor {