From 5dbfafb200af539d24279dbe2b77984cc0bf91fa Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 30 Jun 2017 01:13:00 +0900 Subject: [PATCH] ui: Reserve window position before entering fullscreen-mode (#267) --- internal/ui/ui_glfw.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 0b557b245..19fb2e488 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -40,6 +40,8 @@ type userInterface struct { funcs chan func() running bool sizeChanged bool + origPosX int + origPosY int m sync.Mutex } @@ -72,6 +74,8 @@ func initialize() error { window: window, funcs: make(chan func()), sizeChanged: true, + origPosX: -1, + origPosY: -1, } u.window.MakeContextCurrent() glfw.SwapInterval(1) @@ -347,6 +351,7 @@ func (u *userInterface) setScreenSize(width, height int, scale float64, fullscre m := glfw.GetPrimaryMonitor() v := m.GetVideoMode() if u.fullscreen { + u.origPosX, u.origPosY = window.GetPos() window.SetMonitor(m, 0, 0, v.Width, v.Height, v.RefreshRate) } else { window.SetMonitor(nil, 0, 0, 16, 16, v.RefreshRate) @@ -366,6 +371,10 @@ func (u *userInterface) setScreenSize(width, height int, scale float64, fullscre default: } } + // Reverted from fullscreen + if u.origPosX >= 0 && u.origPosY >= 0 { + window.SetPos(u.origPosX, u.origPosY) + } } // TODO: Rename this variable? u.sizeChanged = true