Skip to content

Commit

Permalink
internal/uidriver/glfw: Bug fix: FramebufferSize callback was not cal…
Browse files Browse the repository at this point in the history
…led when the window size was not changed

Closes #1580
  • Loading branch information
hajimehoshi committed Apr 18, 2021
1 parent 75b0e91 commit 16d3085
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions internal/uidriver/glfw/ui.go
Expand Up @@ -1032,21 +1032,24 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
newW := width
newH := height
if oldW != newW || oldH != newH {
ch := make(chan struct{})
ch := make(chan struct{}, 1)
u.window.SetFramebufferSizeCallback(func(_ *glfw.Window, _, _ int) {
u.window.SetFramebufferSizeCallback(nil)
close(ch)
ch <- struct{}{}
})
u.window.SetSize(newW, newH)
event:
for {
glfw.PollEvents()
select {
case <-ch:
break event
default:
if w, h := u.window.GetSize(); w != oldW || h != oldH {
event:
for {
glfw.PollEvents()
select {
case <-ch:
break event
default:
}
}
}
u.window.SetFramebufferSizeCallback(nil)
close(ch)
}

// Window title might be lost on macOS after coming back from fullscreen.
Expand Down

0 comments on commit 16d3085

Please sign in to comment.