From 280ff84b1c9ab71a3ddf8574091a59c737b2fcb4 Mon Sep 17 00:00:00 2001 From: fufesou Date: Sat, 26 Nov 2022 12:38:12 +0800 Subject: [PATCH] fix remote cursor, when scrollbar is checked Signed-off-by: fufesou --- flutter/lib/desktop/pages/remote_page.dart | 44 ++++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index c0a05c6d5..6d0d9a047 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -506,7 +506,6 @@ class CursorPaint extends StatelessWidget { Widget build(BuildContext context) { final m = Provider.of(context); final c = Provider.of(context); - // final adjust = m.adjustForKeyboard(); double hotx = m.hotx; double hoty = m.hoty; if (m.image == null) { @@ -515,21 +514,34 @@ class CursorPaint extends StatelessWidget { hoty = preDefaultCursor.image!.height / 2; } } - return zoomCursor.isTrue - ? CustomPaint( - painter: ImagePainter( - image: m.image ?? preDefaultCursor.image, - x: m.x - hotx + c.x / c.scale, - y: m.y - hoty + c.y / c.scale, - scale: c.scale), - ) - : CustomPaint( - painter: ImagePainter( - image: m.image ?? preDefaultCursor.image, - x: (m.x - hotx) * c.scale + c.x, - y: (m.y - hoty) * c.scale + c.y, - scale: 1.0), - ); + + double cx = c.x; + double cy = c.y; + if (c.scrollStyle == ScrollStyle.scrollbar) { + final d = c.parent.target!.ffiModel.display; + final imageWidth = d.width * c.scale; + final imageHeight = d.height * c.scale; + cx = -imageWidth * c.scrollX; + cy = -imageHeight * c.scrollY; + } + + double x = (m.x - hotx) * c.scale + cx; + double y = (m.y - hoty) * c.scale + cx; + double scale = 1.0; + if (zoomCursor.isTrue) { + x = m.x - hotx + cx / c.scale; + y = m.y - hoty + cy / c.scale; + scale = c.scale; + } + + return CustomPaint( + painter: ImagePainter( + image: m.image ?? preDefaultCursor.image, + x: x, + y: y, + scale: scale, + ), + ); } }