diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 199b6e6a0..010cd226e 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -1308,3 +1308,15 @@ func (u *UserInterface) maximize() { 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() { + defer u.registerWindowSetSizeCallback() + } + u.window.Restore() + + // 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()) +} diff --git a/internal/uidriver/glfw/window.go b/internal/uidriver/glfw/window.go index 190d9c7a0..ee8df03cb 100644 --- a/internal/uidriver/glfw/window.go +++ b/internal/uidriver/glfw/window.go @@ -170,7 +170,7 @@ func (w *window) Restore() { return } _ = w.ui.t.Call(func() error { - w.ui.window.Restore() + w.ui.restore() return nil }) }