Delete bar NodeIter and use the original swayr one

main
Tassilo Horn 3 years ago
parent 061c3589ac
commit c330a35624
  1. 29
      src/bar/module/window.rs
  2. 2
      src/tree.rs

@ -16,38 +16,11 @@
//! The window `swayrbar` module. //! The window `swayrbar` module.
use crate::bar::module::BarModuleFn; use crate::bar::module::BarModuleFn;
use crate::tree::NodeIter;
use std::cell::RefCell; use std::cell::RefCell;
use swaybar_types as s; use swaybar_types as s;
use swayipc as ipc; 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<Self::Item> {
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 struct BarModuleWindow {
pub instance: String, pub instance: String,
connection: RefCell<swayipc::Connection>, connection: RefCell<swayipc::Connection>,

@ -34,7 +34,7 @@ pub struct NodeIter<'a> {
} }
impl<'a> 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] } NodeIter { stack: vec![node] }
} }
} }

Loading…
Cancel
Save