2024-08-20 19:00:20 -06:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-12 00:42:55 -06:00
|
|
|
handleWaitClose := func () error {
|
|
|
|
handleClose();
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-08-20 19:00:20 -06:00
|
|
|
return event.MultiCookie (
|
|
|
|
window.OnClose(handleClose),
|
2024-09-12 00:42:55 -06:00
|
|
|
event.FuncCookie(handleWaitClose))
|
2024-08-20 19:00:20 -06:00
|
|
|
}
|