summaryrefslogtreecommitdiff
path: root/src/wm_info_provider.rs
blob: 0c6c5fa949d1719f8f0b2062f4da4d3bb0bcd772 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
use std::any::Any;

use wayrs_client::global::*;
use wayrs_client::Connection;

use crate::config::WmConfig;
use crate::pointer_btn::PointerBtn;
use crate::protocol::*;
use crate::state::State;

#[cfg(feature = "hyprland")]
mod ext_workspace_unstable;
#[cfg(feature = "hyprland")]
pub use ext_workspace_unstable::*;

mod river;
pub use river::*;

pub trait WmInfoProvider {
    fn new_ouput(&mut self, conn: &mut Connection<State>, output: WlOutput);
    fn output_removed(&mut self, conn: &mut Connection<State>, output: WlOutput);

    fn get_tags(&self, output: WlOutput) -> Vec<Tag>;
    fn get_layout_name(&self, output: WlOutput) -> Option<String>;
    fn get_mode_name(&self, output: WlOutput) -> Option<String>;

    fn click_on_tag(
        &mut self,
        conn: &mut Connection<State>,
        output: WlOutput,
        seat: WlSeat,
        tag: &str,
        btn: PointerBtn,
    );

    fn as_any(&mut self) -> &mut dyn Any;
}

pub fn bind(
    conn: &mut Connection<State>,
    globals: &Globals,
    config: &WmConfig,
) -> Option<Box<dyn WmInfoProvider>> {
    if let Some(river) = RiverInfoProvider::bind(conn, globals, config) {
        return Some(Box::new(river));
    }

    #[cfg(feature = "hyprland")]
    if let Some(ext_wp_u) = ExtWorkspaceUnstable::bind(conn, globals) {
        return Some(Box::new(ext_wp_u));
    }

    None
}

#[derive(Debug)]
pub struct Tag {
    pub name: String,
    pub is_focused: bool,
    pub is_active: bool,
    pub is_urgent: bool,
}