internal/ui: bug fix: an unfocused window should not wait until buffers are swapped once

On macOS, a window is hidden until buffers are swapped once. If a game is
not runnable on unfocused, as the window is hidden and unfocused, the
waiting loop for a window never ends.

This change fixes the issue by changing the loop condition.

Closes #2620
This commit is contained in:
Hajime Hoshi 2023-04-01 03:01:56 +09:00
parent 140c1ea6c9
commit 2698c6f2c1

View File

@ -1019,7 +1019,7 @@ func (u *userInterfaceImpl) update() (float64, float64, error) {
return 0, 0, err
}
for !u.isRunnableOnUnfocused() && u.window.GetAttrib(glfw.Focused) == 0 && !u.window.ShouldClose() {
for u.bufferOnceSwapped && !u.isRunnableOnUnfocused() && u.window.GetAttrib(glfw.Focused) == 0 && !u.window.ShouldClose() {
if err := hooks.SuspendAudio(); err != nil {
return 0, 0, err
}