hbspbar

bspwm status bar
git clone https://hhvn.uk/hbspbar
git clone git://hhvn.uk/hbspbar
Log | Files | Refs

commit 321045987904f487d533a6666265c506457e9b40
parent d041bda3ef6897bff7d1dc34e30686b502a48374
Author: hhvn <dev@hhvn.uk>
Date:   Fri,  2 Feb 2024 20:29:08 +0000

Ugh. Get rid of drawing goroutines, they just cause issues.

If a goroutine is drawing, and then the bar is destroyed, what happens
then? Etc, etc. Anyway, the multiple goroutines for drawing didn't
actually help, so whatever.

Diffstat:
Mbar/bar.go | 32+++-----------------------------
1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/bar/bar.go b/bar/bar.go @@ -16,16 +16,10 @@ import ( var bars map[int]*bar -type drawinfo struct { - State *bspc.State - Blocks *status.Blocks -} - type bar struct { id int w *drw.Window i *image.RGBA - redraw chan drawinfo } func create(state *bspc.State, id int) (error) { @@ -60,27 +54,10 @@ func (b *bar) init(id int, state *bspc.State) error { rect := image.Rect(0, 0, int(mon.Rectangle.Width), int(config.H)) b.i = image.NewRGBA(rect) - b.redraw = make(chan drawinfo, 20) - - go func(){ - for d := range b.redraw { - // Gobble up excess redraws - gobble: for { - select { - case d = <- b.redraw: - default: break gobble - } - } - - b.draw(d) - } - }() - return nil } func (b *bar) destroy(state *bspc.State) { - close(b.redraw) mon, _ := b.getmon(state) if (mon != nil) { mon.TopPadding(0) @@ -99,13 +76,10 @@ 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(d drawinfo) { +func (b bar) draw(state *bspc.State, blocks *status.Blocks) { var bg color.Color var filled bool - state := d.State - blocks := d.Blocks - mon, err := b.getmon(state) if err != nil { return @@ -247,12 +221,12 @@ func init() { } case blocks = <- status.NewBlocks: for _, b := range bars { - b.redraw <- drawinfo{state, blocks} + b.draw(state, blocks) } case state = <- NewState: finalstate = state for _, b := range bars { - b.redraw <- drawinfo{state, blocks} + b.draw(state, blocks) } } }