/
state.go
184 lines (161 loc) · 3.14 KB
/
state.go
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package clients
import (
"github.com/BurntSushi/xgb/xproto"
"github.com/thrisp/scpwm/euclid/rules"
)
type ClientState int
const (
Focus ClientState = iota
FullScreen
PseudoTiled
Floating
Locked
Sticky
Private
Urgent
Vacant
)
type State interface {
Tiled() bool
Floating() bool
Focused() bool
Pseudotiled() bool
Fullscreen() bool
Get(ClientState) bool
Set(ClientState, bool)
SetState(*rules.Consequence)
}
type state struct {
wmState xproto.Atom
numStates int
focus bool
icccmFocus bool
vacant bool
pseudoTiled bool
floating bool
fullscreen bool
locked bool
sticky bool
urgent bool
private bool
}
func newState(csq *rules.Consequence) State {
s := &state{}
s.SetState(csq)
return s
}
func (s *state) Tiled() bool {
return (!s.floating && !s.fullscreen)
}
func (s *state) Floating() bool {
return (s.floating && !s.fullscreen)
}
func (s *state) Focused() bool {
return s.focus
}
func (s *state) Pseudotiled() bool {
return s.pseudoTiled
}
func (s *state) Fullscreen() bool {
return s.fullscreen
}
func (s *state) Get(cs ClientState) bool {
switch cs {
case Focus:
return s.focus
case FullScreen:
return s.fullscreen
case PseudoTiled:
return s.pseudoTiled
case Floating:
return s.floating
case Locked:
return s.locked
case Sticky:
return s.sticky
case Private:
return s.private
case Urgent:
return s.urgent
case Vacant:
return s.vacant
}
return false
}
func (s *state) Set(cs ClientState, v bool) {
switch cs {
case Focus:
s.setFocus(v)
case FullScreen:
s.setFullScreen(v)
case PseudoTiled:
s.setPseudoTiled(v)
case Floating:
s.setFloating(v)
case Locked:
s.setLocked(v)
case Sticky:
s.setSticky(v)
case Private:
s.setPrivate(v)
case Urgent:
s.setUrgent(v)
case Vacant:
s.setVacant(v)
}
}
func (s *state) setFocus(v bool) {
s.focus = v
}
func (s *state) setFullScreen(v bool) {
s.fullscreen = v
//if v {
//ewmh_wm_state_add(c, ewmh->_NET_WM_STATE_FULLSCREEN);
//} else {
//ewmh_wm_state_remove(c, ewmh->_NET_WM_STATE_FULLSCREEN);
//stack(n, STACK_ABOVE);
//}
}
func (s *state) setPseudoTiled(v bool) {
s.pseudoTiled = v
}
func (s *state) setFloating(v bool) {
s.floating, s.vacant = v, v
//update_vacant_state(n->parent);
//if v {
// enable_floating_atom(c->window);
// unrotate_brother(n);
//} else {
// disable_floating_atom(c->window);
// rotate_brother(n);
//}
//stack(n, STACK_ABOVE);
}
func (s *state) setLocked(v bool) {
s.locked = v
//window_draw_border(n, d->focus == n, m == mon);
}
func (s *state) setSticky(v bool) {
s.sticky = v
//if (value) {
// ewmh_wm_state_add(c, ewmh->_NET_WM_STATE_STICKY);
// m->num_sticky++;
// } else {
// ewmh_wm_state_remove(c, ewmh->_NET_WM_STATE_STICKY);
// m->num_sticky--;
// }
// window_draw_border(n, d->focus == n, m == mon);
}
func (s *state) setPrivate(v bool) {
s.private = v
//update_privacy_level(n, value);
//window_draw_border(n, d->focus == n, m == mon);
}
func (s *state) setUrgent(v bool) {
s.urgent = v
//window_draw_border(n, d->focus == n, m == mon);
}
func (s *state) setVacant(v bool) {
s.vacant = v
}
func (s *state) SetState(csq *rules.Consequence) {}