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
68
69
use std::fmt;

/// Actions that may be applied to a `wmctrl::Window`
pub enum Action {
    Remove,
    Add,
    Toggle,
}

impl fmt::Display for Action {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Action::Remove => write!(f, "remove"),
            Action::Add => write!(f, "add"),
            Action::Toggle => write!(f, "toggle"),
        }
    }
}

/// Properties that may be applied to a `wmctrl::Window`
pub enum Property {
    Modal,
    Sticky,
    MaximizedVert,
    MaximizedHorz,
    Shaded,
    SkipTaskbar,
    SkipPager,
    Hidden,
    Fullscreen,
    Above,
    Below,
}

impl fmt::Display for Property {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
            Property::Modal => write!(f, "modal"),
            Property::Sticky => write!(f, "sticky"),
            Property::MaximizedVert => write!(f, "maximized_vert"),
            Property::MaximizedHorz => write!(f, "maximized_horz"),
            Property::Shaded => write!(f, "shaded"),
            Property::SkipTaskbar => write!(f, "skip_taskbar"),
            Property::SkipPager => write!(f, "skip_pager"),
            Property::Hidden => write!(f, "hidden"),
            Property::Fullscreen => write!(f, "fullscreen"),
            Property::Above => write!(f, "above"),
            Property::Below => write!(f, "below"),
        }
    }
}

/// Holds information about the new state of a `wmctrl::Window`.
pub struct State {
    action: Action,
    property: Property,
}

impl State {
    pub fn new(action: Action, property: Property) -> State {
        State { action, property }
    }
}

impl fmt::Display for State {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{},{}", self.action, self.property)
    }
}