From 7adfd6e5c641f7543fcf87e4c558579dc652fdf7 Mon Sep 17 00:00:00 2001 From: hhvn Date: Tue, 22 Aug 2023 12:50:03 +0100 Subject: Drawing desktops --- bspc/bspc.go | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'bspc') 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 } }}() -- cgit v1.2.3