summaryrefslogtreecommitdiff
path: root/src/shared_state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared_state.rs')
-rw-r--r--src/shared_state.rs16
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")
+ })
+ }
+}