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::xwindow::Xwindow; use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; use crate::ifs::wl_surface::WlSurface; use crate::tree::{ContainerNode, DisplayNode, FloatNode, Node, OutputNode, WorkspaceNode}; use std::rc::Rc; pub trait NodeVisitorBase: Sized { fn visit_surface(&mut self, node: &Rc) { node.visit_children(self); } fn visit_container(&mut self, node: &Rc) { node.visit_children(self); } fn visit_toplevel(&mut self, node: &Rc) { node.visit_children(self); } fn visit_popup(&mut self, node: &Rc) { node.visit_children(self); } fn visit_display(&mut self, node: &Rc) { node.visit_children(self); } fn visit_output(&mut self, node: &Rc) { node.visit_children(self); } fn visit_float(&mut self, node: &Rc) { node.visit_children(self); } fn visit_workspace(&mut self, node: &Rc) { node.visit_children(self); } fn visit_layer_surface(&mut self, node: &Rc) { node.visit_children(self); } fn visit_xwindow(&mut self, node: &Rc) { node.visit_children(self); } } pub trait NodeVisitor { fn visit_surface(&mut self, node: &Rc); fn visit_container(&mut self, node: &Rc); fn visit_toplevel(&mut self, node: &Rc); fn visit_popup(&mut self, node: &Rc); fn visit_display(&mut self, node: &Rc); fn visit_output(&mut self, node: &Rc); fn visit_float(&mut self, node: &Rc); fn visit_workspace(&mut self, node: &Rc); fn visit_layer_surface(&mut self, node: &Rc); fn visit_xwindow(&mut self, node: &Rc); } impl NodeVisitor for T { fn visit_surface(&mut self, node: &Rc) { ::visit_surface(self, node) } fn visit_container(&mut self, node: &Rc) { ::visit_container(self, node) } fn visit_toplevel(&mut self, node: &Rc) { ::visit_toplevel(self, node) } fn visit_popup(&mut self, node: &Rc) { ::visit_popup(self, node) } fn visit_display(&mut self, node: &Rc) { ::visit_display(self, node) } fn visit_output(&mut self, node: &Rc) { ::visit_output(self, node) } fn visit_float(&mut self, node: &Rc) { ::visit_float(self, node) } fn visit_workspace(&mut self, node: &Rc) { ::visit_workspace(self, node) } fn visit_layer_surface(&mut self, node: &Rc) { ::visit_layer_surface(self, node) } fn visit_xwindow(&mut self, node: &Rc) { ::visit_xwindow(self, node) } } // pub fn visit_containers)>(f: F) -> impl NodeVisitor { // struct V(F); // impl)> NodeVisitorBase for V { // fn visit_container(&mut self, node: &Rc) { // (self.0)(node); // node.visit_children(self); // } // } // V(f) // } // // pub fn visit_floats)>(f: F) -> impl NodeVisitor { // struct V(F); // impl)> NodeVisitorBase for V { // fn visit_float(&mut self, node: &Rc) { // (self.0)(node); // node.visit_children(self); // } // } // V(f) // }