ui: Bug fix: the window is shown on the current monitor on Windows

Fixes #704
This commit is contained in:
Hajime Hoshi 2018-10-08 03:24:12 +09:00
parent 96a657025f
commit 8d2820efb0

View File

@ -516,6 +516,10 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
// swapping buffers. // swapping buffers.
opengl.Init(currentUI.runOnMainThread) opengl.Init(currentUI.runOnMainThread)
_ = u.runOnMainThread(func() error { _ = u.runOnMainThread(func() error {
// Get the monitor before calling setScreenSize. On Windows, setScreenSize can affect the
// monitor where the hidden window is shown.
m := u.currentMonitor()
// The game is in window mode (not fullscreen mode) at the first state. // The game is in window mode (not fullscreen mode) at the first state.
// Don't refer u.initFullscreen here to avoid some GLFW problems. // Don't refer u.initFullscreen here to avoid some GLFW problems.
u.setScreenSize(width, height, scale, false, u.vsync) u.setScreenSize(width, height, scale, false, u.vsync)
@ -523,7 +527,6 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
u.window.SetTitle(title) u.window.SetTitle(title)
u.window.Show() u.window.Show()
m := u.currentMonitor()
mx, my := m.GetPos() mx, my := m.GetPos()
v := m.GetVideoMode() v := m.GetVideoMode()
w, h := u.glfwSize() w, h := u.glfwSize()