From c330a356249ca4843705d53672666c7924617083 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 1 Apr 2022 22:08:20 +0200 Subject: [PATCH] Delete bar NodeIter and use the original swayr one --- src/bar/module/window.rs | 29 +---------------------------- src/tree.rs | 2 +- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/bar/module/window.rs b/src/bar/module/window.rs index c05525a..ee5fbe5 100644 --- a/src/bar/module/window.rs +++ b/src/bar/module/window.rs @@ -16,38 +16,11 @@ //! The window `swayrbar` module. use crate::bar::module::BarModuleFn; +use crate::tree::NodeIter; use std::cell::RefCell; use swaybar_types as s; use swayipc as ipc; -pub struct NodeIter<'a> { - stack: Vec<&'a ipc::Node>, -} - -impl<'a> NodeIter<'a> { - fn new(node: &'a ipc::Node) -> NodeIter { - NodeIter { stack: vec![node] } - } -} - -impl<'a> Iterator for NodeIter<'a> { - type Item = &'a ipc::Node; - - fn next(&mut self) -> Option { - if let Some(node) = self.stack.pop() { - for n in &node.floating_nodes { - self.stack.push(n); - } - for n in &node.nodes { - self.stack.push(n); - } - Some(node) - } else { - None - } - } -} - pub struct BarModuleWindow { pub instance: String, connection: RefCell, diff --git a/src/tree.rs b/src/tree.rs index 688a0d4..7b9b181 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -34,7 +34,7 @@ pub struct NodeIter<'a> { } impl<'a> NodeIter<'a> { - fn new(node: &'a s::Node) -> NodeIter { + pub fn new(node: &'a s::Node) -> NodeIter { NodeIter { stack: vec![node] } } }