diff options
| author | hhvn <dev@hhvn.uk> | 2024-02-02 20:29:08 +0000 |
|---|---|---|
| committer | hhvn <dev@hhvn.uk> | 2024-02-02 20:29:38 +0000 |
| commit | 321045987904f487d533a6666265c506457e9b40 (patch) | |
| tree | 609de2cf4b5c14bb09a1e47eeb09a3a7008685ed /bar/bar.go | |
| parent | d041bda3ef6897bff7d1dc34e30686b502a48374 (diff) | |
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 (limited to 'bar/bar.go')
| -rw-r--r-- | bar/bar.go | 32 |
1 files changed, 3 insertions, 29 deletions
@@ -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) } } } |