refresh neither leaks wraps, allows 2 of the same at once, nor closes raws

This commit is contained in:
bel
2023-03-25 10:50:39 -06:00
parent 97cc3ae151
commit ae1e32391c
18 changed files with 94 additions and 64 deletions

View File

@@ -3,6 +3,7 @@ package wrap
import (
"context"
"mayhem-party/src/device/input/button"
"mayhem-party/src/device/input/raw"
"os"
)
@@ -15,6 +16,7 @@ var (
type Wrap interface {
Read() []button.Button
Close()
CloseWrap() raw.Raw
}
func New(ctx context.Context, srcFunc func() button.Parser) Wrap {
@@ -36,7 +38,7 @@ func New(ctx context.Context, srcFunc func() button.Parser) Wrap {
if FlagRefreshOnSigUsr1 {
oldMaker := maker
maker = func() Wrap {
return NewRefresh(oldMaker)
return NewRefresh(ctx, oldMaker)
}
}
return maker()