From eb5c1ee8181d57f154494924f244081dedaee69a Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 5 Jul 2023 09:24:26 +0900 Subject: [PATCH] internal/ui: bug fix: the original cursor position was not scaled correctly Updates #2690 --- internal/ui/input_js.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/ui/input_js.go b/internal/ui/input_js.go index f2c9ab7b4..b909a9903 100644 --- a/internal/ui/input_js.go +++ b/internal/ui/input_js.go @@ -112,10 +112,11 @@ func (u *userInterfaceImpl) setMouseCursorFromEvent(e js.Value) { return } + s := u.DeviceScaleFactor() + x, y := u.context.clientPositionToLogicalPosition(e.Get("clientX").Float(), e.Get("clientY").Float(), s) + u.origCursorX, u.origCursorY = int(x), int(y) + if u.cursorMode == CursorModeCaptured { - x, y := e.Get("clientX").Int(), e.Get("clientY").Int() - u.origCursorX, u.origCursorY = x, y - s := u.DeviceScaleFactor() dx, dy := e.Get("movementX").Float()/s, e.Get("movementY").Float()/s // TODO: Keep float64 values. u.inputState.CursorX += int(dx) @@ -123,9 +124,7 @@ func (u *userInterfaceImpl) setMouseCursorFromEvent(e js.Value) { return } - x, y := u.context.clientPositionToLogicalPosition(e.Get("clientX").Float(), e.Get("clientY").Float(), u.DeviceScaleFactor()) u.inputState.CursorX, u.inputState.CursorY = int(x), int(y) - u.origCursorX, u.origCursorY = int(x), int(y) } func (u *userInterfaceImpl) recoverCursorPosition() {