app,io/system: [API] add StageInactive when window is not in focus

Now, Gio will send one system.StageEvent with system.StageInactive when
the window is not active. It is implemented on macOS and Windows.

This change is not fully backward compatible, if your code compares
the Stage (`stage < system.StageRunning`), you need to consider
the new system.StageInactive.

Signed-off-by: inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
Inkeliz
2022-08-20 17:30:50 +01:00
committed by Elias Naur
parent b1dba5f27d
commit 90688fdd17
6 changed files with 32 additions and 9 deletions
+3 -3
View File
@@ -552,7 +552,7 @@ func Java_org_gioui_GioView_onLowMemory(env *C.JNIEnv, class C.jclass) {
func Java_org_gioui_GioView_onConfigurationChanged(env *C.JNIEnv, class C.jclass, view C.jlong) {
w := cgo.Handle(view).Value().(*window)
w.loadConfig(env, class)
if w.stage >= system.StageRunning {
if w.stage >= system.StageInactive {
w.draw(env, true)
}
}
@@ -563,7 +563,7 @@ func Java_org_gioui_GioView_onFrameCallback(env *C.JNIEnv, class C.jclass, view
if !exist {
return
}
if w.stage < system.StageRunning {
if w.stage < system.StageInactive {
return
}
if w.animating {
@@ -596,7 +596,7 @@ func Java_org_gioui_GioView_onWindowInsets(env *C.JNIEnv, class C.jclass, view C
left: int(left),
right: int(right),
}
if w.stage >= system.StageRunning {
if w.stage >= system.StageInactive {
w.draw(env, true)
}
}