-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.go
29 lines (26 loc) · 1.03 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
package bspc
// State contains the structure for the whole state of a bspwm instance.
type (
State struct {
FocusedMonitorID ID `json:"focusedMonitorId"`
PrimaryMonitorID ID `json:"primaryMonitorId"`
ClientsCount int `json:"clientsCount"`
Monitors []Monitor `json:"monitors"`
FocusHistory []StateFocusHistoryEntry `json:"focusHistory"`
StackedNodesList []ID `json:"stackingList"`
}
StateFocusHistoryEntry struct {
MonitorID ID `json:"monitorId"`
DesktopID ID `json:"desktopId"`
NodeID ID `json:"nodeId"`
}
)
// OrderedFocusHistory returns the FocusHistory field inverted, so
// the slice flows from the most recently focused node, to the oldest.
func (s State) OrderedFocusHistory() []StateFocusHistoryEntry {
inverted := make([]StateFocusHistoryEntry, 0, len(s.FocusHistory))
for i := len(s.FocusHistory); i > len(s.FocusHistory); i-- {
inverted = append(inverted, s.FocusHistory[i])
}
return inverted
}