1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
use std::any::Any;
use crate::{
blocks_cache::BlocksCache,
config::Config,
icon::IconCache,
status_cmd::StatusCmd,
tray::{TrayHandle, TrayItem},
wm_info_provider::{self, WmInfoProvider},
};
use wayrs_utils::shm_alloc::ShmAlloc;
pub struct SharedState {
pub shm: ShmAlloc,
pub config: Config,
pub status_cmd: Option<StatusCmd>,
pub blocks_cache: BlocksCache,
pub icon_cache: IconCache,
pub wm_info_provider: Box<dyn WmInfoProvider>,
pub tray: Option<TrayHandle>,
pub tray_items: Vec<TrayItem>,
pub tray_expanded: bool,
}
impl SharedState {
fn downcast_provider<T: Any>(&mut self) -> Option<&mut T> {
<dyn Any>::downcast_mut(self.wm_info_provider.as_mut())
}
#[cfg(feature = "river")]
pub fn get_river(&mut self) -> Option<&mut wm_info_provider::RiverInfoProvider> {
self.downcast_provider()
}
#[cfg(feature = "hyprland")]
pub fn get_hyprland(&mut self) -> Option<&mut wm_info_provider::HyprlandInfoProvider> {
self.downcast_provider()
}
#[cfg(feature = "niri")]
pub fn get_niri(&mut self) -> Option<&mut wm_info_provider::NiriInfoProvider> {
self.downcast_provider()
}
#[cfg(feature = "mango")]
pub fn get_mango(&mut self) -> Option<&mut wm_info_provider::MangoInfoProvider> {
self.downcast_provider()
}
}
|