ui: Bug fix: a window was alwasy 'unfocused' on Windows

There is an issue in GLFW that a window was recognized as unfoces
on Windows (glfw/glfw#1573). As a workaround, skip the logic for
an unfocused window on Windows. On Windows, even if a window is in
another workspace, vsync works. Then there seems no problem.

Fixes #987
This commit is contained in:
Hajime Hoshi 2019-11-17 14:10:35 +09:00
parent cfc66efcfb
commit 800b98a0c6

View File

@ -823,7 +823,14 @@ func (u *UserInterface) loop(context driver.UIContext) error {
}) })
}() }()
for { for {
unfocused := u.window.GetAttrib(glfw.Focused) == glfw.False var unfocused bool
// On Windows, the focusing state might be always false (#987).
// On Windows, even if a window is in another workspace, vsync seems to work.
// Then let's assume the window is alwasy 'focused' as a workaround.
if runtime.GOOS != "windows" {
unfocused = u.window.GetAttrib(glfw.Focused) == glfw.False
}
var t1, t2 time.Time var t1, t2 time.Time