internal/uidriver/glfw: Bug fix: Crash at Iconify

This is the same reason as Maximize.

Updates #1576
This commit is contained in:
Hajime Hoshi 2021-04-18 01:03:06 +09:00
parent b5d4c834b8
commit f09cf7fa47
2 changed files with 14 additions and 2 deletions

View File

@ -1322,7 +1322,7 @@ func (u *UserInterface) Window() driver.Window {
}
func (u *UserInterface) maximize() {
// Maximizing invokes the SetSize callback but the callback must not be called in the game's Update (#1576).
// Maximize invokes the SetSize callback but the callback must not be called in the game's Update (#1576).
if u.unregisterWindowSetSizeCallback() {
defer u.registerWindowSetSizeCallback()
}
@ -1333,6 +1333,18 @@ func (u *UserInterface) maximize() {
u.setWindowSize(w, h, u.isFullscreen())
}
func (u *UserInterface) iconify() {
// Iconify invokes the SetSize callback but the callback must not be called in the game's Update (#1576).
if u.unregisterWindowSetSizeCallback() {
defer u.registerWindowSetSizeCallback()
}
u.window.Iconify()
// Call setWindowSize explicitly in order to update the rendering since the callback is unregistered now.
w, h := u.window.GetSize()
u.setWindowSize(w, h, u.isFullscreen())
}
func (u *UserInterface) restore() {
// Restore invokes the SetSize callback but the callback must not be called in the game's Update (#1576).
if u.unregisterWindowSetSizeCallback() {

View File

@ -159,7 +159,7 @@ func (w *window) Minimize() {
return
}
_ = w.ui.t.Call(func() error {
w.ui.window.Iconify()
w.ui.iconify()
return nil
})
}