ui: Show the window on the current monitor (#704)

Tested on macOS. This doesn't work on Windows yet since there are
some codes that depends on the primary monitor.
This commit is contained in:
Hajime Hoshi 2018-10-08 00:46:00 +09:00
parent fb7a3f2736
commit effd530026

View File

@ -508,10 +508,12 @@ 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()
v := u.currentMonitor().GetVideoMode() m := u.currentMonitor()
mx, my := m.GetPos()
v := m.GetVideoMode()
w, h := u.glfwSize() w, h := u.glfwSize()
x := (v.Width - w) / 2 x := mx + (v.Width-w)/2
y := (v.Height - h) / 3 y := my + (v.Height-h)/3
x, y = adjustWindowPosition(x, y) x, y = adjustWindowPosition(x, y)
u.window.SetPos(x, y) u.window.SetPos(x, y)
return nil return nil