From 09d2459f1c155ad59f6afde16d748b0d0d286768 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 1 Apr 2023 03:35:43 +0900 Subject: [PATCH] internal/ui: a more robust fix for the unfocused-window loop Depending on the member variable bufferOnceSwapped is a little fragile. Detect whether the window is shown or not instead. Updates #2620 --- internal/ui/ui_glfw.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 1c2fcd236..592557f3e 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -1019,7 +1019,8 @@ func (u *userInterfaceImpl) update() (float64, float64, error) { return 0, 0, err } - for u.bufferOnceSwapped && !u.isRunnableOnUnfocused() && u.window.GetAttrib(glfw.Focused) == 0 && !u.window.ShouldClose() { + // In the initial state on macOS, the window is not shown (#2620). + for u.window.GetAttrib(glfw.Visible) != 0 && !u.isRunnableOnUnfocused() && u.window.GetAttrib(glfw.Focused) == 0 && !u.window.ShouldClose() { if err := hooks.SuspendAudio(); err != nil { return 0, 0, err }