Skip to content

Commit

Permalink
internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer
Browse files Browse the repository at this point in the history
In case when the callback is not called, let's use timeout.

Updates hajimehoshi#1618
  • Loading branch information
hajimehoshi committed Apr 22, 2021
1 parent ea06454 commit 8b11008
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions internal/uidriver/glfw/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,15 +1042,21 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
ch <- struct{}{}
})
u.window.SetSize(newW, newH)
if w, h := u.window.GetSize(); w != oldW || h != oldH {
event:
for {
glfw.PollEvents()
select {
case <-ch:
break event
default:
}
// Just after SetSize, GetSize is not reliable especially on Linux/Windows.
// Let's wait for FramebufferSize callback in any cases.

// Use the timeout as FramebufferSize event might not be fired (#1618).
t := time.NewTimer(time.Second)
defer t.Stop()
event:
for {
glfw.PollEvents()
select {
case <-ch:
break event
case <-t.C:
break event
default:
}
}
u.window.SetFramebufferSizeCallback(nil)
Expand Down

0 comments on commit 8b11008

Please sign in to comment.