From 6aeb76407a30309326a04b29d19e5390a4b96248 Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Sat, 26 Aug 2023 16:56:58 +0300 Subject: rework wm_info_provider stuff --- src/bar.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/bar.rs') diff --git a/src/bar.rs b/src/bar.rs index 5f24478..45fbc88 100644 --- a/src/bar.rs +++ b/src/bar.rs @@ -14,7 +14,7 @@ use crate::protocol::*; use crate::shared_state::SharedState; use crate::state::State; use crate::text::{self, ComputedText, RenderOptions}; -use crate::wm_info_provider::WmInfo; +use crate::wm_info_provider::Tag; pub struct Bar { pub output: Output, @@ -29,7 +29,8 @@ pub struct Bar { pub viewport: WpViewport, pub fractional_scale: Option, pub blocks_btns: ButtonManager<(Option, Option)>, - pub wm_info: WmInfo, + pub tags: Vec, + pub layout_name: Option, pub tags_btns: ButtonManager, pub tags_computed: Vec<(ColorPair, ComputedText)>, pub layout_name_computed: Option, @@ -42,10 +43,14 @@ pub struct ColorPair { } impl Bar { - pub fn set_wm_info(&mut self, info: WmInfo) { - self.wm_info = info; + pub fn set_tags(&mut self, tags: Vec) { + self.tags = tags; self.tags_btns.clear(); self.tags_computed.clear(); + } + + pub fn set_layout_name(&mut self, layout_name: Option) { + self.layout_name = layout_name; self.layout_name_computed = None; } @@ -59,8 +64,9 @@ impl Bar { _y: f64, ) -> anyhow::Result<()> { if let Some(tag) = self.tags_btns.click(x) { - ss.wm_info_provider - .click_on_tag(conn, self.output.wl, seat, tag, button); + if let Some(wm) = &mut ss.wm_info_provider { + wm.click_on_tag(conn, self.output.wl, seat, tag, button); + } } else if let Some((name, instance)) = self.blocks_btns.click(x) { if let Some(cmd) = &mut ss.status_cmd { cmd.send_click_event(&i3bar_protocol::Event { @@ -137,7 +143,7 @@ impl Bar { if self.tags_computed.is_empty() { let mut offset_left = 0.0; self.tags_btns.clear(); - for tag in &self.wm_info.tags { + for tag in &self.tags { let (bg, fg) = if tag.is_urgent { (ss.config.tag_urgent_bg, ss.config.tag_urgent_fg) } else if tag.is_focused { @@ -187,7 +193,7 @@ impl Bar { // Display layout name if ss.config.show_layout_name { - if let Some(layout_name) = &self.wm_info.layout_name { + if let Some(layout_name) = &self.layout_name { let text = self.layout_name_computed.get_or_insert_with(|| { ComputedText::new( layout_name, -- cgit v1.3.1