From 1ead096f676827e16ea2eaf63213ce3bf9a33d8e Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 22 Sep 2020 18:40:52 +0900 Subject: [PATCH] uidriver/glfw: Bug fix: Need to call updateVsync after setWindowSize Fixes #1363 --- internal/uidriver/glfw/ui.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 9b733223b..7f88f5485 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -811,6 +811,17 @@ func (u *UserInterface) update(context driver.UIContext) error { u.setInitFullscreen(false) } + // Initialize vsync after SetMonitor is called. See the comment in updateVsync. + // Calling this inside setWindowSize didn't work (#1363). + _ = u.t.Call(func() error { + if !u.vsyncInited { + u.vsync = u.isInitVsyncEnabled() + u.updateVsync() + u.vsyncInited = true + } + return nil + }) + // This call is needed for initialization. u.updateSize(context) @@ -1026,13 +1037,6 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) { u.windowWidth = width u.windowHeight = height - if !u.vsyncInited { - // Initialize vsync after SetMonitor is called. See the comment in updateVsync. - u.vsync = u.isInitVsyncEnabled() - u.updateVsync() - u.vsyncInited = true - } - u.toChangeSize = true return nil })