Skip to content

Commit

Permalink
internal/ui: bug fix: InitUnfocused option didn't work
Browse files Browse the repository at this point in the history
Updates #2924
Closes #3099
  • Loading branch information
hajimehoshi committed Sep 14, 2024
1 parent 098380c commit dc5869f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/ui/ui_glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ type userInterfaceImpl struct {
initWindowMaximized bool
initWindowMousePassthrough bool

initUnfocused bool

// bufferOnceSwapped must be accessed from the main thread.
bufferOnceSwapped bool

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit dc5869f

Please sign in to comment.