From 8cca713d7419e0d78cf6b9088d1f72c60d362228 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 28 Mar 2020 21:26:57 +0900 Subject: [PATCH] uidriver/glfw: Bug fix: adjustWindowPosition should consider the monitor position --- internal/uidriver/glfw/ui_darwin.go | 2 +- internal/uidriver/glfw/ui_unix.go | 2 +- internal/uidriver/glfw/ui_windows.go | 11 ++++++----- internal/uidriver/glfw/window.go | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/uidriver/glfw/ui_darwin.go b/internal/uidriver/glfw/ui_darwin.go index c500f4c6f..89da75b69 100644 --- a/internal/uidriver/glfw/ui_darwin.go +++ b/internal/uidriver/glfw/ui_darwin.go @@ -51,7 +51,7 @@ func (u *UserInterface) glfwScale() float64 { return 1 } -func adjustWindowPosition(x, y int) (int, int) { +func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { return x, y } diff --git a/internal/uidriver/glfw/ui_unix.go b/internal/uidriver/glfw/ui_unix.go index d7cc5fa7f..1859f551e 100644 --- a/internal/uidriver/glfw/ui_unix.go +++ b/internal/uidriver/glfw/ui_unix.go @@ -28,7 +28,7 @@ func (u *UserInterface) glfwScale() float64 { return u.deviceScaleFactor() } -func adjustWindowPosition(x, y int) (int, int) { +func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { return x, y } diff --git a/internal/uidriver/glfw/ui_windows.go b/internal/uidriver/glfw/ui_windows.go index 757e42abb..9700701a9 100644 --- a/internal/uidriver/glfw/ui_windows.go +++ b/internal/uidriver/glfw/ui_windows.go @@ -103,18 +103,19 @@ func (u *UserInterface) glfwScale() float64 { return u.deviceScaleFactor() } -func adjustWindowPosition(x, y int) (int, int) { +func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { + mx, my := u.currentMonitor().GetPos() // As the video width/height might be wrong, // adjust x/y at least to enable to handle the window (#328) - if x < 0 { - x = 0 + if x < mx { + x = mx } t, err := getSystemMetrics(smCyCaption) if err != nil { panic(err) } - if y < t { - y = t + if y < my + t { + y = my + t } return x, y } diff --git a/internal/uidriver/glfw/window.go b/internal/uidriver/glfw/window.go index 20b751240..7c1541ec6 100644 --- a/internal/uidriver/glfw/window.go +++ b/internal/uidriver/glfw/window.go @@ -205,7 +205,7 @@ func (w *window) SetPosition(x, y int) { mx, my := w.ui.currentMonitor().GetPos() xf := w.ui.toDeviceDependentPixel(float64(x)) yf := w.ui.toDeviceDependentPixel(float64(y)) - x, y := adjustWindowPosition(mx+int(xf), my+int(yf)) + x, y := w.ui.adjustWindowPosition(mx+int(xf), my+int(yf)) if w.ui.isFullscreen() { w.ui.origPosX, w.ui.origPosY = x, y } else {