mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer
In case when the callback is not called, let's use timeout. Updates #1618
This commit is contained in:
parent
ed62bffff1
commit
b726d19b00
@ -1208,17 +1208,24 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
|
|||||||
ch <- struct{}{}
|
ch <- struct{}{}
|
||||||
})
|
})
|
||||||
u.window.SetSize(newW, newH)
|
u.window.SetSize(newW, newH)
|
||||||
if w, h := u.window.GetSize(); w != oldW || h != oldH {
|
// 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:
|
event:
|
||||||
for {
|
for {
|
||||||
glfw.PollEvents()
|
glfw.PollEvents()
|
||||||
select {
|
select {
|
||||||
case <-ch:
|
case <-ch:
|
||||||
break event
|
break event
|
||||||
|
case <-t.C:
|
||||||
|
break event
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
u.window.SetFramebufferSizeCallback(nil)
|
u.window.SetFramebufferSizeCallback(nil)
|
||||||
close(ch)
|
close(ch)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user