diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2023-04-17 12:26:43 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2023-04-17 12:26:43 +0300 |
| commit | d3b488c95817c75ad6ac892e9826da8d9dd189b3 (patch) | |
| tree | ae7c6b93c89e8bc574446de2e6f4bea349b3cc63 /src/state.rs | |
| parent | eed0b89aafaee8146688c4ca05146986bbd4dc37 (diff) | |
| download | i3bar-mango-d3b488c95817c75ad6ac892e9826da8d9dd189b3.tar.gz | |
refactor cache management
Diffstat (limited to 'src/state.rs')
| -rw-r--r-- | src/state.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/state.rs b/src/state.rs index 0f8e4a7..86eb45d 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,3 +1,4 @@ +use crate::blocks_cache::BlocksCache; use crate::protocol::*; use crate::wm_info_provider::*; @@ -13,7 +14,7 @@ use wayrs_utils::shm_alloc::ShmAlloc; use crate::{ bar::Bar, config::Config, i3bar_protocol::Block, pointer_btn::PointerBtn, - shared_state::SharedState, status_cmd::StatusCmd, text::ComputedText, wm_info_provider, + shared_state::SharedState, status_cmd::StatusCmd, wm_info_provider, }; pub struct State { @@ -84,8 +85,7 @@ impl State { shm: ShmAlloc::new(wl_shm), config, status_cmd, - blocks: Vec::new(), - blocks_cache: Vec::new(), + blocks_cache: BlocksCache::default(), wm_info_provider: wm_info_provider::bind_wayland(conn, globals, wm_info_cb), }, @@ -105,7 +105,9 @@ impl State { } pub fn set_blocks(&mut self, conn: &mut Connection<Self>, blocks: Vec<Block>) { - self.shared_state.blocks = blocks; + self.shared_state + .blocks_cache + .process_new_blocks(&self.shared_state.config, &blocks); self.draw_all(conn); } @@ -448,14 +450,6 @@ fn wm_info_cb(conn: &mut Connection<State>, state: &mut State, output: WlOutput, bar.request_frame(conn); } -#[derive(Debug)] -pub struct ComputedBlock { - pub block: Block, - pub full: ComputedText, - pub short: Option<ComputedText>, - pub min_width: Option<f64>, -} - #[derive(Debug, Default, Clone, Copy)] pub struct ScrollFrame { stop: bool, |
