internal/uidriver/glfw: Bug fix: Need to reregister the callback after recreating the window

Updates #1588
Closes #1593
This commit is contained in:
Hajime Hoshi 2021-04-19 01:28:56 +09:00
parent 73f90f324f
commit dcaa1f9722

View File

@ -705,12 +705,13 @@ func (u *UserInterface) createWindow() error {
u.window.SetTitle(u.title) u.window.SetTitle(u.title)
// TODO: Set icons // TODO: Set icons
u.registerWindowSetSizeCallback()
return nil return nil
} }
// registerWindowSetSizeCallback must be called from the main thread. // registerWindowSetSizeCallback must be called from the main thread.
func (u *UserInterface) registerWindowSetSizeCallback() { func (u *UserInterface) registerWindowSetSizeCallback() {
u.setSizeCallbackEnabled = true
u.window.SetSizeCallback(func(_ *glfw.Window, width, height int) { u.window.SetSizeCallback(func(_ *glfw.Window, width, height int) {
if !u.setSizeCallbackEnabled { if !u.setSizeCallbackEnabled {
return return
@ -802,7 +803,7 @@ func (u *UserInterface) init() error {
if err := u.createWindow(); err != nil { if err := u.createWindow(); err != nil {
return err return err
} }
u.registerWindowSetSizeCallback() u.setSizeCallbackEnabled = true
setPosition := func() { setPosition := func() {
u.iwindow.setPosition(u.getInitWindowPosition()) u.iwindow.setPosition(u.getInitWindowPosition())