From 321045987904f487d533a6666265c506457e9b40 Mon Sep 17 00:00:00 2001 From: hhvn Date: Fri, 2 Feb 2024 20:29:08 +0000 Subject: 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. --- bar/bar.go | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'bar') diff --git a/bar/bar.go b/bar/bar.go index 9660844..2a543d3 100644 --- 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) } } } -- cgit v1.2.3