summaryrefslogtreecommitdiff
path: root/bspc
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-08-22 12:50:03 +0100
committerhhvn <dev@hhvn.uk>2023-08-22 12:50:03 +0100
commit7adfd6e5c641f7543fcf87e4c558579dc652fdf7 (patch)
tree6dc7c3d5f487a4913a61fa5f55b4356ef1a57bf0 /bspc
parent1c3013dfcbbfb33cbfaf616c1b44051e35d7746c (diff)
Drawing desktops
Diffstat (limited to 'bspc')
-rw-r--r--bspc/bspc.go40
1 files changed, 29 insertions, 11 deletions
diff --git a/bspc/bspc.go b/bspc/bspc.go
index f88d839..4c5f9e7 100644
--- a/bspc/bspc.go
+++ b/bspc/bspc.go
@@ -12,7 +12,8 @@ import (
)
type State struct {
- Monitors []*Monitor
+ Monitors []*Monitor
+ FocusedMonitorID int
}
func (s *State) GetMon(id int) (*Monitor) {
@@ -26,9 +27,12 @@ func (s *State) GetMon(id int) (*Monitor) {
}
type Monitor struct {
- ID int
- Rectangle *Rect
- Desktops []*Desktop
+ Focused bool
+ ID int
+ Name string
+ Rectangle *Rect
+ Desktops []*Desktop
+ FocusedDesktopID int
}
func (m *Monitor) TopPadding(px uint) {
@@ -59,9 +63,18 @@ type Rect struct {
Height uint
}
+type Node struct {
+ ID int
+ FirstChild *Node
+ SecondChild *Node
+}
+
type Desktop struct {
- Name string
- Layout string
+ Focused bool
+ Name string
+ Layout string
+ ID int
+ Root *Node
}
func LoadState() (*State, error) {
@@ -91,6 +104,14 @@ func LoadState() (*State, error) {
return nil, common.Perror("json.Unmarshal", err)
}
+ for _, m := range state.Monitors {
+ m.Focused = m.ID == state.FocusedMonitorID
+
+ for _, d := range m.Desktops {
+ d.Focused = d.ID == m.FocusedDesktopID
+ }
+ }
+
return &state, nil
}
@@ -128,11 +149,8 @@ func Subscribe() (*Subscriber, error) {
s.scanner = bufio.NewScanner(s.pipe)
go func() { for {
- select {
- default:
- if event := s.get(); event != nil {
- s.Event <- event
- }
+ if event := s.get(); event != nil {
+ s.Event <- event
}
}}()