internal/ui: bug fix: use the native unit for origWindowPosByOS

This commit is contained in:
Hajime Hoshi 2022-04-08 16:43:13 +09:00
parent 90070c09fe
commit 2008916261

View File

@ -394,11 +394,10 @@ func (u *userInterfaceImpl) origWindowPosByOS() (int, int, bool) {
if !u.isNativeFullscreen() { if !u.isNativeFullscreen() {
return invalidPos, invalidPos, true return invalidPos, invalidPos, true
} }
m := u.currentMonitor()
var cx, cy C.int var cx, cy C.int
C.windowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), &cx, &cy) C.windowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), &cx, &cy)
x := int(u.dipFromGLFWPixel(float64(cx), m)) x := int(cx)
y := int(u.dipFromGLFWPixel(float64(flipY(int(cy))), m)) - u.windowHeightInDIP y := flipY(int(cy)) - u.windowHeightInDIP
return x, y, true return x, y, true
} }
@ -406,9 +405,8 @@ func (u *userInterfaceImpl) setOrigWindowPosByOS(x, y int) bool {
if !u.isNativeFullscreen() { if !u.isNativeFullscreen() {
return true return true
} }
m := u.currentMonitor() cx := C.int(x)
cx := C.int(u.dipToGLFWPixel(float64(x), m)) cy := C.int(flipY(y + u.windowHeightInDIP))
cy := C.int(flipY(int(u.dipToGLFWPixel(float64(y+u.windowHeightInDIP), m))))
C.setWindowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), cx, cy) C.setWindowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), cx, cy)
return true return true
} }