From 8d2820efb09c2b90d18616d34268137ad33ad821 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 8 Oct 2018 03:24:12 +0900 Subject: [PATCH] ui: Bug fix: the window is shown on the current monitor on Windows Fixes #704 --- internal/ui/ui_glfw.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index f8e102d61..3cf8b7817 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -516,6 +516,10 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main // swapping buffers. opengl.Init(currentUI.runOnMainThread) _ = 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. // Don't refer u.initFullscreen here to avoid some GLFW problems. 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.Show() - m := u.currentMonitor() mx, my := m.GetPos() v := m.GetVideoMode() w, h := u.glfwSize()