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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use crate::{
hooks,
layout::{side_stack, Layout, LayoutConf},
};
pub type ResizeAction = (WinId, Option<Region>);
pub type WinId = u32;
#[derive(Debug, Copy, Clone)]
pub struct Point {
pub x: u32,
pub y: u32,
}
impl Point {
pub fn new(x: u32, y: u32) -> Point {
Point { x, y }
}
}
pub struct Config<'a> {
pub workspaces: Vec<&'a str>,
pub floating_classes: &'static [&'static str],
pub layouts: Vec<Layout>,
pub focused_border: u32,
pub unfocused_border: u32,
pub border_px: u32,
pub gap_px: u32,
pub main_ratio_step: f32,
pub show_bar: bool,
pub top_bar: bool,
pub bar_height: u32,
pub hooks: Vec<Box<dyn hooks::Hook>>,
}
impl<'a> Config<'a> {
pub fn default() -> Config<'a> {
Config {
workspaces: vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"],
floating_classes: &["dmenu", "dunst"],
layouts: vec![
Layout::new("[side]", LayoutConf::default(), side_stack, 1, 0.6),
Layout::floating("[----]"),
],
focused_border: 0xcc241d,
unfocused_border: 0x3c3836,
border_px: 2,
gap_px: 5,
main_ratio_step: 0.05,
show_bar: true,
top_bar: true,
bar_height: 18,
hooks: vec![],
}
}
pub fn ws_range(&self) -> std::ops::Range<usize> {
1..(self.workspaces.len() + 1)
}
}
#[derive(Debug, Copy, Clone)]
pub enum Change {
More,
Less,
}
#[derive(Debug)]
pub enum Border {
Urgent,
Focused,
Unfocused,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Region {
x: u32,
y: u32,
w: u32,
h: u32,
}
impl Region {
pub fn new(x: u32, y: u32, w: u32, h: u32) -> Region {
Region { x, y, w, h }
}
pub fn values(&self) -> (u32, u32, u32, u32) {
(self.x, self.y, self.w, self.h)
}
}