From cb4085277bea70231ed4a02b53770d5ed03f78a4 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 7 Feb 2022 23:51:40 +0900 Subject: [PATCH] internal/ui: bug fix: adjust the window position correctly Updates #1982 --- internal/ui/ui_glfw.go | 2 +- internal/ui/ui_glfw_darwin.go | 2 +- internal/ui/ui_glfw_unix.go | 2 +- internal/ui/ui_glfw_windows.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 7a8356f40..5421ca749 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -1603,7 +1603,7 @@ func (u *UserInterface) setWindowPositionInDIP(x, y int, monitor *glfw.Monitor) mx, my := monitor.GetPos() xf := u.dipToGLFWPixel(float64(x), monitor) yf := u.dipToGLFWPixel(float64(y), monitor) - if x, y := u.adjustWindowPosition(mx+int(xf), my+int(yf)); u.isFullscreen() { + if x, y := u.adjustWindowPosition(mx+int(xf), my+int(yf), monitor); u.isFullscreen() { u.setOrigPos(x, y) } else { u.window.SetPos(x, y) diff --git a/internal/ui/ui_glfw_darwin.go b/internal/ui/ui_glfw_darwin.go index 400d74b88..097310ea3 100644 --- a/internal/ui/ui_glfw_darwin.go +++ b/internal/ui/ui_glfw_darwin.go @@ -154,7 +154,7 @@ func (u *UserInterface) dipToGLFWPixel(x float64, monitor *glfw.Monitor) float64 return x } -func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { +func (u *UserInterface) adjustWindowPosition(x, y int, monitor *glfw.Monitor) (int, int) { return x, y } diff --git a/internal/ui/ui_glfw_unix.go b/internal/ui/ui_glfw_unix.go index 01c4ded63..eb7b70fd9 100644 --- a/internal/ui/ui_glfw_unix.go +++ b/internal/ui/ui_glfw_unix.go @@ -129,7 +129,7 @@ func (u *UserInterface) dipToGLFWPixel(x float64, monitor *glfw.Monitor) float64 return x * u.deviceScaleFactor(monitor) } -func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { +func (u *UserInterface) adjustWindowPosition(x, y int, monitor *glfw.Monitor) (int, int) { return x, y } diff --git a/internal/ui/ui_glfw_windows.go b/internal/ui/ui_glfw_windows.go index 72f40db12..e5beed0c4 100644 --- a/internal/ui/ui_glfw_windows.go +++ b/internal/ui/ui_glfw_windows.go @@ -115,8 +115,8 @@ func (u *UserInterface) dipToGLFWPixel(x float64, monitor *glfw.Monitor) float64 return x * u.deviceScaleFactor(monitor) } -func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { - mx, my := u.currentMonitor().GetPos() +func (u *UserInterface) adjustWindowPosition(x, y int, monitor *glfw.Monitor) (int, int) { + mx, my := monitor.GetPos() // As the video width/height might be wrong, // adjust x/y at least to enable to handle the window (#328) if x < mx {