From 85e7c72ccd69dd2ae415ef3a72f08d21118294c4 Mon Sep 17 00:00:00 2001 From: fufesou Date: Sat, 12 Sep 2026 14:29:40 +0800 Subject: [PATCH] test(cursor): clarify scale constraints and isolate DPR checks --- flutter/lib/desktop/pages/remote_page.dart | 4 ++++ flutter/test/cursor_dpi_policy_test.dart | 3 ++- flutter/test/cursor_web_test.dart | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 12f8f365c..e10a9c15d 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -1421,15 +1421,19 @@ class CursorPaint extends StatelessWidget { final image = m.image ?? preDefaultCursor.image; final nativePixels = isWindows ? MediaQuery.devicePixelRatioOf(context) : 1.0; + // Show remote cursor follows the image scale, independently of Zoom cursor. double scale = c.scale; if (image != null && scale * nativePixels != 1.0) { final sx = kMinCursorSize / (image.width * nativePixels); final sy = kMinCursorSize / (image.height * nativePixels); + // Preserve Original's short-edge minimum; scaled views use the long edge. final minimumScale = c.viewStyle.style == kRemoteViewStyleOriginal ? (sx > sy ? sx : sy) : (sx < sy ? sx : sy); if (scale < minimumScale) scale = minimumScale; } + // Keep the hotspot at the remote position even when the minimum enlarges + // the cursor; fractional coordinates must survive painting below. final x = (m.x * c.scale + cx) / scale - hotx; final y = (m.y * c.scale + cy) / scale - hoty; diff --git a/flutter/test/cursor_dpi_policy_test.dart b/flutter/test/cursor_dpi_policy_test.dart index f3877a852..f06a75718 100644 --- a/flutter/test/cursor_dpi_policy_test.dart +++ b/flutter/test/cursor_dpi_policy_test.dart @@ -211,7 +211,8 @@ Future _checkPolicy( Future _checkDprChange( TestFlutterView view, List> registrations) async { - final data = await _data(1, 'dpr-cache'); + // Keep the scale above the minimum so only DPR invalidates the cache. + final data = await _data(2, 'dpr-cache'); final canvas = _Canvas(1, style: kRemoteViewStyleAdaptive, scale: 1); final cursor = _Cursor(data, _FFI(canvas)); for (final dpr in [2.0, 1.0]) { diff --git a/flutter/test/cursor_web_test.dart b/flutter/test/cursor_web_test.dart index b76d45cbe..8e0dbf32a 100644 --- a/flutter/test/cursor_web_test.dart +++ b/flutter/test/cursor_web_test.dart @@ -1,3 +1,6 @@ +// The test drives the cursor lifecycle normally owned by MouseTracker. +// ignore_for_file: invalid_use_of_protected_member + @TestOn('browser') library;