Skip to content

Commit

Permalink
internal/ui: bug fix: skip focus check for the first update
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Sep 14, 2024
1 parent 9a511fe commit 99ffe09
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/ui/ui_glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type userInterfaceImpl struct {

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

origWindowPosX int
origWindowPosY int
Expand Down Expand Up @@ -1276,6 +1277,10 @@ func (u *UserInterface) setFPSMode(fpsMode FPSModeType) error {

// update must be called from the main thread.
func (u *UserInterface) update() (float64, float64, error) {
defer func() {
u.updateOnceCalled = true
}()

if err := u.error(); err != nil {
return 0, 0, err
}
Expand Down Expand Up @@ -1383,7 +1388,9 @@ func (u *UserInterface) update() (float64, float64, error) {
}
}

for !u.isRunnableOnUnfocused() {
// If isRunnableOnUnfocused is false and the window is not focused, wait here.
// For the first update, skip this check as the window might not be seen yet in some environments like ChromeOS (#3091).
for !u.isRunnableOnUnfocused() && u.updateOnceCalled {
// In the initial state on macOS, the window is not shown (#2620).
visible, err := u.window.GetAttrib(glfw.Visible)
if err != nil {
Expand Down

0 comments on commit 99ffe09

Please sign in to comment.