From ca2fe22e4a1c9e2e31cbdc1be3c12c5a52c0d1bf Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 6 Oct 2018 03:53:34 +0900 Subject: [PATCH] ui: Bug fix: Set the proper window position when coming back from fullscreen --- internal/ui/ui_glfw.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index a4bafa2af..063d16d3d 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -713,12 +713,10 @@ func (u *userInterface) forceSetScreenSize(width, height int, scale float64, ful v := m.GetVideoMode() u.window.SetMonitor(m, 0, 0, v.Width, v.Height, v.RefreshRate) } else { - if u.origPosX >= 0 && u.origPosY >= 0 { - x := u.origPosX - y := u.origPosY - u.window.SetMonitor(nil, x, y, 16, 16, 0) - u.origPosX = -1 - u.origPosY = -1 + if u.window.GetMonitor() != nil { + // Give dummy values as the window position and size. + // The new window position should be specifying after SetSize. + u.window.SetMonitor(nil, 0, 0, 16, 16, 0) } oldW, oldH := u.window.GetSize() @@ -740,6 +738,15 @@ func (u *userInterface) forceSetScreenSize(width, height int, scale float64, ful } } } + + if u.origPosX >= 0 && u.origPosY >= 0 { + x := u.origPosX + y := u.origPosY + u.window.SetPos(x, y) + u.origPosX = -1 + u.origPosY = -1 + } + // Window title might be lost on macOS after coming back from fullscreen. u.window.SetTitle(u.title) }