loop: Bug fix: the clock needs to be stopped when the window is unfocused

This commit is contained in:
Hajime Hoshi 2017-07-16 23:54:14 +09:00
parent f591ca3d2b
commit 717efd097d

View File

@ -143,7 +143,13 @@ func (c *runContext) updateCount(now int64) int {
}
c.lastClockFrame = f
} else {
count = int(t * int64(clock.FPS) / int64(time.Second))
if t > 5*int64(time.Second)/int64(clock.FPS) {
// The previous time is too old. Let's assume that the window was unfocused.
count = 0
c.lastUpdated = now
} else {
count = int(t * int64(clock.FPS) / int64(time.Second))
}
}
// Stabilize FPS.