From dc5869f6075ffe3db3fedf411ef74c4063aeba19 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 14 Sep 2024 17:28:35 +0900 Subject: [PATCH] internal/ui: bug fix: InitUnfocused option didn't work Updates #2924 Closes #3099 --- internal/ui/ui_glfw.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index a5136ac04..7877e6ae1 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -81,6 +81,8 @@ type userInterfaceImpl struct { initWindowMaximized bool initWindowMousePassthrough bool + initUnfocused bool + // bufferOnceSwapped must be accessed from the main thread. bufferOnceSwapped bool @@ -1087,6 +1089,7 @@ func (u *UserInterface) initOnMainThread(options *RunOptions) error { return err } + u.initUnfocused = options.InitUnfocused focused := glfw.True if options.InitUnfocused { focused = glfw.False @@ -1288,8 +1291,10 @@ func (u *UserInterface) update() (float64, float64, error) { if err = u.window.Show(); err != nil { return } - if err = u.window.Focus(); err != nil { - return + if !u.initUnfocused { + if err = u.window.Focus(); err != nil { + return + } } if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {