summaryrefslogtreecommitdiff
path: root/bar
diff options
context:
space:
mode:
Diffstat (limited to 'bar')
-rw-r--r--bar/bar.go29
1 files changed, 14 insertions, 15 deletions
diff --git a/bar/bar.go b/bar/bar.go
index 2a543d3..e7d66ff 100644
--- a/bar/bar.go
+++ b/bar/bar.go
@@ -76,10 +76,14 @@ func (b *bar) drawRect(x, y, w, h int, c color.Color, fill bool) {
drw.DrawRect(b.i, x, y, w, h, c, fill)
}
-func (b bar) draw(state *bspc.State, blocks *status.Blocks) {
+func (b bar) draw(state *bspc.State, blocks []*status.Block) {
var bg color.Color
var filled bool
+ if blocks == nil {
+ return
+ }
+
mon, err := b.getmon(state)
if err != nil {
return
@@ -137,29 +141,24 @@ func (b bar) draw(state *bspc.State, blocks *status.Blocks) {
cx += ax + 2
}
- cx = int(mon.Rectangle.Width) - 6
- for i := blocks.Len() - 1; i >= 0; i -= 1 {
- s, ok := blocks.Get(i)
- if ok {
+ cx = int(mon.Rectangle.Width)
+ for _, s := range blocks {
+ if s != nil {
cx -= s.W
cx -= config.StatusPad
}
}
- cx += config.StatusPad
- cx -= 6
b.drawRect(cx, 0, int(mon.Rectangle.Width) - cx, int(config.H),
config.Status, true)
- cx = int(mon.Rectangle.Width) - 6
- for i := blocks.Len() - 1; i >= 0; i -= 1 {
- s, ok := blocks.Get(i)
- if ok {
- cx -= s.W
+ cx += config.StatusPad / 2
+ for _, s := range blocks {
+ if s != nil {
drw.AddImg(b.i, cx, s.W, s.I)
- cx -= config.StatusPad
+ cx += s.W + config.StatusPad
}
}
@@ -176,8 +175,8 @@ var Err = make(chan error)
var finalstate *bspc.State = nil
func init() {
- var state *bspc.State = nil
- var blocks *status.Blocks = nil
+ var state *bspc.State = nil
+ var blocks []*status.Block = nil
go func() {
defer func() {