internal/uidriver/glfw: Bug fix: FramebufferSize callback was not called when the window size was not changed

Closes #1580
This commit is contained in:
Hajime Hoshi 2021-04-18 15:22:32 +09:00
parent 61c0908b13
commit fda1fd9a95

View File

@ -1177,21 +1177,24 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
newW := width newW := width
newH := height newH := height
if oldW != newW || oldH != newH { if oldW != newW || oldH != newH {
ch := make(chan struct{}) ch := make(chan struct{}, 1)
u.window.SetFramebufferSizeCallback(func(_ *glfw.Window, _, _ int) { u.window.SetFramebufferSizeCallback(func(_ *glfw.Window, _, _ int) {
u.window.SetFramebufferSizeCallback(nil) ch <- struct{}{}
close(ch)
}) })
u.window.SetSize(newW, newH) u.window.SetSize(newW, newH)
event: if w, h := u.window.GetSize(); w != oldW || h != oldH {
for { event:
glfw.PollEvents() for {
select { glfw.PollEvents()
case <-ch: select {
break event case <-ch:
default: break event
default:
}
} }
} }
u.window.SetFramebufferSizeCallback(nil)
close(ch)
} }
// Window title might be lost on macOS after coming back from fullscreen. // Window title might be lost on macOS after coming back from fullscreen.