diff options
| author | MaxVerevkin <maxxverrr@gmail.com> | 2022-08-27 09:16:12 +0300 |
|---|---|---|
| committer | MaxVerevkin <maxxverrr@gmail.com> | 2022-08-27 09:19:12 +0300 |
| commit | f0e53e6b8119d872f5986c3fcb4403d7b8214382 (patch) | |
| tree | b5392afd381f7ccdfe081c2d180581ae1113a0cc /src/shared_state.rs | |
| parent | a68c55c3462fa9c716a4d286a11cc451ac917800 (diff) | |
| download | i3bar-mango-f0e53e6b8119d872f5986c3fcb4403d7b8214382.tar.gz | |
refactor
Diffstat (limited to 'src/shared_state.rs')
| -rw-r--r-- | src/shared_state.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/shared_state.rs b/src/shared_state.rs index c4ec9d6..554d856 100644 --- a/src/shared_state.rs +++ b/src/shared_state.rs @@ -1,4 +1,7 @@ -use smithay_client_toolkit::{reexports::client::QueueHandle, shm::slot::SlotPool}; +use smithay_client_toolkit::{ + reexports::client::QueueHandle, + shm::{slot::SlotPool, ShmState}, +}; use crate::{ config::Config, @@ -10,9 +13,18 @@ use crate::{ #[derive(Debug)] pub struct SharedState { pub qh: QueueHandle<State>, - pub pool: SlotPool, + pub shm_state: ShmState, + pub pool: Option<SlotPool>, pub config: Config, pub status_cmd: Option<StatusCmd>, pub blocks: Vec<Block>, pub blocks_cache: Vec<ComputedBlock>, } + +impl SharedState { + pub fn get_pool(&mut self, len: usize) -> &mut SlotPool { + self.pool.get_or_insert_with(|| { + SlotPool::new(len, &self.shm_state).expect("Failed to create pool") + }) + } +} |
