diff --git a/src/main.rs b/src/main.rs index dd5fea8..475c22d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,16 +3,10 @@ mod wayland; use crate::wayland::river_status_unstable_v1::{ zriver_output_status_v1, zriver_seat_status_v1, zriver_status_manager_v1::ZriverStatusManagerV1, }; -use std::collections::HashMap; +use std::collections::BTreeMap; use wayland_client::protocol::{wl_output, wl_output::WlOutput, wl_seat, wl_seat::WlSeat}; use wayland_client::{Display, GlobalManager, Main}; -#[derive(Debug)] -enum Value { - Tags(u32), - ViewsTag(Vec), -} - #[derive(Debug)] struct Flags { tags: bool, @@ -36,12 +30,13 @@ impl Flags { } } +#[derive(Debug)] struct Env { flags: Flags, title: Option, - tags: HashMap, - urgency: HashMap, - viewstag: HashMap>, + tags: BTreeMap, + urgency: BTreeMap, + viewstag: BTreeMap>, status_manager: Option>, } @@ -50,30 +45,12 @@ impl Env { Env { title: None, flags: configuration(), - viewstag: HashMap::new(), - urgency: HashMap::new(), - tags: HashMap::new(), + viewstag: BTreeMap::new(), + urgency: BTreeMap::new(), + tags: BTreeMap::new(), status_manager: None, } } - fn set_value(&mut self, key: &str, value: Value) { - match value { - Value::Tags( tags ) => { - if let Some(inner_value) = self.tags.get_mut(key) { - (*inner_value) = tags; - } else { - self.tags.insert(key.to_string(), tags); - } - } - Value::ViewsTag( tags ) => { - if let Some(inner_value) = self.viewstag.get_mut(key) { - (*inner_value) = tags; - } else { - self.viewstag.insert(key.to_string(), tags); - } - } - } - } fn fmt(&self) { if !self.tags.is_empty() || !self.viewstag.is_empty() @@ -207,7 +184,11 @@ fn main() { tags, } => { if env.flags.tags { - env.set_value(&make, Value::Tags(tags)); + if let Some(inner_value) = env.tags.get_mut(&make) { + (*inner_value) = tags; + } else { + env.tags.insert(make.clone(), tags); + } } } zriver_output_status_v1::Event::ViewTags { @@ -228,10 +209,11 @@ fn main() { 0 }) .collect(); - env.set_value( - &make, - Value::ViewsTag(tags), - ); + if let Some(inner_value) = env.viewstag.get_mut(&make) { + (*inner_value) = tags; + } else { + env.viewstag.insert(make.clone(), tags); + } } } zriver_output_status_v1::Event::UrgentTags { @@ -241,6 +223,7 @@ fn main() { if let Some(inner_value) = env.urgency.get_mut(&make) { (*inner_value) = tags; } else { + // println!("{}", tags); env.urgency.insert(make.clone(), tags); } }