summaryrefslogtreecommitdiff
path: root/src/wm_info_provider.rs
blob: 12e4fb8d0b06fdf785de6e3fe12167100dff6c3a (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
63
64
65
66
67
mod river;

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

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

pub enum WmInfoProvider {
    None,
    River(river::RiverInfoProvider),
}

pub type WmInfoCallback = fn(&mut Connection<State>, &mut State, WlOutput, WmInfo);

impl WmInfoProvider {
    pub fn bind(
        conn: &mut Connection<State>,
        globals: &Globals,
        callback: WmInfoCallback,
    ) -> WmInfoProvider {
        let Some(river) = river::RiverInfoProvider::bind(conn, globals, callback) else { return Self::None };
        Self::River(river)
    }

    pub fn new_ouput(&mut self, conn: &mut Connection<State>, output: WlOutput) {
        match self {
            Self::None => (),
            Self::River(river) => river.new_output(conn, output),
        }
    }

    pub fn output_removed(&mut self, conn: &mut Connection<State>, output: WlOutput) {
        match self {
            Self::None => (),
            Self::River(river) => river.output_removed(conn, output),
        }
    }

    pub fn click_on_tag(
        &mut self,
        conn: &mut Connection<State>,
        output: WlOutput,
        seat: WlSeat,
        tag: &str,
        btn: PointerBtn,
    ) {
        match self {
            Self::None => (),
            Self::River(river) => river.click_on_tag(conn, output, seat, tag, btn),
        }
    }
}

#[derive(Default)]
pub struct WmInfo {
    pub layout_name: Option<String>,
    pub tags: Vec<Tag>,
}

pub struct Tag {
    pub name: String,
    pub is_focused: bool,
    pub is_active: bool,
    pub is_urgent: bool,
}