From 816f0e901fc63244fcfd130e1345406963b542d8 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 18 Sep 2019 19:28:08 +0200 Subject: [PATCH] ui/app: scale touch events by surface scale Signed-off-by: Elias Naur --- ui/app/os_wayland.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/app/os_wayland.go b/ui/app/os_wayland.go index 6d883ce9..be14ebf4 100644 --- a/ui/app/os_wayland.go +++ b/ui/app/os_wayland.go @@ -451,7 +451,10 @@ func gio_onRegistryGlobalRemove(data unsafe.Pointer, reg *C.struct_wl_registry, func gio_onTouchDown(data unsafe.Pointer, touch *C.struct_wl_touch, serial, t C.uint32_t, surf *C.struct_wl_surface, id C.int32_t, x, y C.wl_fixed_t) { w := winMap[surf] winMap[touch] = w - w.lastTouch = f32.Point{X: fromFixed(x), Y: fromFixed(y)} + w.lastTouch = f32.Point{ + X: fromFixed(x) * float32(w.scale), + Y: fromFixed(y) * float32(w.scale), + } w.w.event(pointer.Event{ Type: pointer.Press, Source: pointer.Touch, @@ -476,7 +479,10 @@ func gio_onTouchUp(data unsafe.Pointer, touch *C.struct_wl_touch, serial, t C.ui //export gio_onTouchMotion func gio_onTouchMotion(data unsafe.Pointer, touch *C.struct_wl_touch, t C.uint32_t, id C.int32_t, x, y C.wl_fixed_t) { w := winMap[touch] - w.lastTouch = f32.Point{X: fromFixed(x), Y: fromFixed(y)} + w.lastTouch = f32.Point{ + X: fromFixed(x) * float32(w.scale), + Y: fromFixed(y) * float32(w.scale), + } w.w.event(pointer.Event{ Type: pointer.Move, Position: w.lastTouch,