uidriver/js: Implement IsForeground

Updates #1037
This commit is contained in:
Hajime Hoshi 2020-01-21 23:56:47 +09:00
parent db40554715
commit 38f49c3768

View File

@ -77,8 +77,7 @@ func (u *UserInterface) IsFullscreen() bool {
}
func (u *UserInterface) IsForeground() bool {
// TODO: implement this
return true
return u.isForeground()
}
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
@ -146,14 +145,17 @@ func (u *UserInterface) suspended() bool {
if u.runnableInBackground {
return false
}
return !u.isForeground()
}
func (u *UserInterface) isForeground() bool {
if !document.Call("hasFocus").Bool() {
return true
return false
}
if document.Get("hidden").Bool() {
return true
return false
}
return false
return true
}
func (u *UserInterface) update() error {