From 0c4ef7ee8ee1079e2c931abbdc8ae9901959f37e Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 14 Oct 2018 16:59:14 +0900 Subject: [PATCH] ui: Bug fix: fix the initial window position on multiple monitors --- internal/ui/ui_glfw.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 44b3efe9b..72c79f460 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -533,17 +533,20 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main // current window will be the active window. Thus, currentMonitor retuls varies before and after // showing the window. m := u.currentMonitor() + mx, my := m.GetPos() + v := m.GetVideoMode() // 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) + // Get the window size before showing since window.Show might change the current + // monitor which affects glfwSize result. + w, h := u.glfwSize() + u.title = title u.window.SetTitle(title) u.window.Show() - mx, my := m.GetPos() - v := m.GetVideoMode() - w, h := u.glfwSize() x := mx + (v.Width-w)/2 y := my + (v.Height-h)/3 x, y = adjustWindowPosition(x, y)