diff options
| author | Max Verevkin <34583604+MaxVerevkin@users.noreply.github.com> | 2022-11-27 21:25:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-27 21:25:15 +0200 |
| commit | d28693c9d293ea7c348c0e9e1a4e89ccff6dcae4 (patch) | |
| tree | 0794e56251e223388463a84d09616ef47a918bb4 /src/shared_state.rs | |
| parent | 9ddde2d2ee9833412e39afbd1ed907cdea22f08f (diff) | |
| parent | d45a4ef408c0f5a2071194d4c3285f0b7cb27dd0 (diff) | |
| download | i3bar-mango-d28693c9d293ea7c348c0e9e1a4e89ccff6dcae4.tar.gz | |
Merge pull request #1 from MaxVerevkin/next
Rewrite using latest walayd libs & implement HiDPI
Diffstat (limited to 'src/shared_state.rs')
| -rw-r--r-- | src/shared_state.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/shared_state.rs b/src/shared_state.rs new file mode 100644 index 0000000..554d856 --- /dev/null +++ b/src/shared_state.rs @@ -0,0 +1,30 @@ +use smithay_client_toolkit::{ + reexports::client::QueueHandle, + shm::{slot::SlotPool, ShmState}, +}; + +use crate::{ + config::Config, + i3bar_protocol::Block, + state::{ComputedBlock, State}, + status_cmd::StatusCmd, +}; + +#[derive(Debug)] +pub struct SharedState { + pub qh: QueueHandle<State>, + 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") + }) + } +} |
