34 lines
622 B
Go
34 lines
622 B
Go
package nasin
|
|
|
|
import "git.tebibyte.media/tomo/tomo"
|
|
import "git.tebibyte.media/tomo/tomo/event"
|
|
|
|
var manager struct {
|
|
count int
|
|
}
|
|
|
|
// WaitFor ensures that the application will stay running while the given window
|
|
// is open.
|
|
func WaitFor (window tomo.Window) event.Cookie {
|
|
manager.count ++
|
|
|
|
isManaged := true
|
|
handleClose := func () {
|
|
if !isManaged { return }
|
|
isManaged = false
|
|
manager.count --
|
|
if manager.count < 1 {
|
|
tomo.Stop()
|
|
}
|
|
}
|
|
|
|
handleWaitClose := func () error {
|
|
handleClose();
|
|
return nil
|
|
}
|
|
|
|
return event.MultiCookie (
|
|
window.OnClose(handleClose),
|
|
event.FuncCookie(handleWaitClose))
|
|
}
|