aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-08-28 18:59:22 -0400
committerSam Anthony <sam@samanthony.xyz>2024-08-28 18:59:22 -0400
commit353e3e0ea23143773710487f67cdccc8c02b4478 (patch)
tree6a9c03a94698789459a7e77748244df7d9c42b08
parent33713cb2334d8dce3e4ae2f7a7905104efa8519b (diff)
downloadgui-rev1.zip
win: implement Envrev1
-rw-r--r--win.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/win.go b/win.go
index 2868f5c..7c8b5ef 100644
--- a/win.go
+++ b/win.go
@@ -75,6 +75,8 @@ type Win struct {
img share.Val[*image.RGBA]
ratio int
+ child killer
+
kill chan bool
dead chan bool
@@ -104,6 +106,7 @@ func NewWin(opts ...WinOption) (*Win, error) {
draw: make(chan func(draw.Image) image.Rectangle),
newSize: make(chan image.Rectangle),
img: share.NewVal[*image.RGBA](),
+ child: newKiller(),
kill: make(chan bool),
dead: make(chan bool),
threads: new(sync.WaitGroup),
@@ -181,6 +184,12 @@ func (w *Win) Events() <-chan Event { return w.events.Dequeue }
// Draw returns the draw channel of the window.
func (w *Win) Draw() chan<- func(draw.Image) image.Rectangle { return w.draw }
+func (w *Win) Kill() chan<- bool { return w.kill }
+
+func (w *Win) Dead() <-chan bool { return w.dead }
+
+func (w *Win) attach() chan<- victim { return w.child.attach() }
+
var buttons = map[glfw.MouseButton]Button{
glfw.MouseButtonLeft: ButtonLeft,
glfw.MouseButtonRight: ButtonRight,
@@ -270,6 +279,9 @@ func (w *Win) eventThread() {
for {
select {
case <-w.kill:
+ w.child.Kill() <- true
+ <-w.child.Dead()
+
close(w.kill)
close(w.events.Enqueue)
close(w.draw)