uidriver/glfw: Bug fix: adjustWindowPosition should consider the monitor position

This commit is contained in:
Hajime Hoshi 2020-03-28 21:26:57 +09:00
parent 0a5126f776
commit 8cca713d74
4 changed files with 9 additions and 8 deletions

View File

@ -51,7 +51,7 @@ func (u *UserInterface) glfwScale() float64 {
return 1 return 1
} }
func adjustWindowPosition(x, y int) (int, int) { func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
return x, y return x, y
} }

View File

@ -28,7 +28,7 @@ func (u *UserInterface) glfwScale() float64 {
return u.deviceScaleFactor() return u.deviceScaleFactor()
} }
func adjustWindowPosition(x, y int) (int, int) { func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
return x, y return x, y
} }

View File

@ -103,18 +103,19 @@ func (u *UserInterface) glfwScale() float64 {
return u.deviceScaleFactor() 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, // As the video width/height might be wrong,
// adjust x/y at least to enable to handle the window (#328) // adjust x/y at least to enable to handle the window (#328)
if x < 0 { if x < mx {
x = 0 x = mx
} }
t, err := getSystemMetrics(smCyCaption) t, err := getSystemMetrics(smCyCaption)
if err != nil { if err != nil {
panic(err) panic(err)
} }
if y < t { if y < my + t {
y = t y = my + t
} }
return x, y return x, y
} }

View File

@ -205,7 +205,7 @@ func (w *window) SetPosition(x, y int) {
mx, my := w.ui.currentMonitor().GetPos() mx, my := w.ui.currentMonitor().GetPos()
xf := w.ui.toDeviceDependentPixel(float64(x)) xf := w.ui.toDeviceDependentPixel(float64(x))
yf := w.ui.toDeviceDependentPixel(float64(y)) 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() { if w.ui.isFullscreen() {
w.ui.origPosX, w.ui.origPosY = x, y w.ui.origPosX, w.ui.origPosY = x, y
} else { } else {