From dbbd9179b76094f6cca72cc5d658409159b54938 Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:42:08 +0800 Subject: [PATCH] fix: android cursor scale (#8478) * fix: android cursor scale Signed-off-by: fufesou * Min scale restriction for mobile cursor Signed-off-by: fufesou --------- Signed-off-by: fufesou --- flutter/lib/mobile/pages/remote_page.dart | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index c86df2242..f86d35a1c 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -927,7 +927,7 @@ class CursorPaint extends StatelessWidget { final m = Provider.of(context); final c = Provider.of(context); final adjust = gFFI.cursorModel.adjustForKeyboard(); - var s = c.scale; + final s = c.scale; double hotx = m.hotx; double hoty = m.hoty; if (m.image == null) { @@ -936,12 +936,22 @@ class CursorPaint extends StatelessWidget { hoty = preDefaultCursor.image!.height / 2; } } + + final image = m.image ?? preDefaultCursor.image; + final minSize = 24.0; + double mins = + minSize / (image!.width > image.height ? image.width : image.height); + double factor = 1.0; + if (s < mins) { + factor = s / mins; + } + final s2 = s < mins ? mins : s; return CustomPaint( painter: ImagePainter( - image: m.image ?? preDefaultCursor.image, - x: m.x * s - hotx + c.x, - y: m.y * s - hoty + c.y - adjust, - scale: 1), + image: image, + x: (m.x - hotx) * factor + c.x / s2, + y: (m.y - hoty) * factor + (c.y - adjust) / s2, + scale: s2), ); } }