mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-15 00:41:01 +03:00
test(cursor): clarify scale constraints and isolate DPR checks
This commit is contained in:
@@ -1421,15 +1421,19 @@ class CursorPaint extends StatelessWidget {
|
|||||||
|
|
||||||
final image = m.image ?? preDefaultCursor.image;
|
final image = m.image ?? preDefaultCursor.image;
|
||||||
final nativePixels = isWindows ? MediaQuery.devicePixelRatioOf(context) : 1.0;
|
final nativePixels = isWindows ? MediaQuery.devicePixelRatioOf(context) : 1.0;
|
||||||
|
// Show remote cursor follows the image scale, independently of Zoom cursor.
|
||||||
double scale = c.scale;
|
double scale = c.scale;
|
||||||
if (image != null && scale * nativePixels != 1.0) {
|
if (image != null && scale * nativePixels != 1.0) {
|
||||||
final sx = kMinCursorSize / (image.width * nativePixels);
|
final sx = kMinCursorSize / (image.width * nativePixels);
|
||||||
final sy = kMinCursorSize / (image.height * 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
|
final minimumScale = c.viewStyle.style == kRemoteViewStyleOriginal
|
||||||
? (sx > sy ? sx : sy)
|
? (sx > sy ? sx : sy)
|
||||||
: (sx < sy ? sx : sy);
|
: (sx < sy ? sx : sy);
|
||||||
if (scale < minimumScale) scale = minimumScale;
|
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 x = (m.x * c.scale + cx) / scale - hotx;
|
||||||
final y = (m.y * c.scale + cy) / scale - hoty;
|
final y = (m.y * c.scale + cy) / scale - hoty;
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,8 @@ Future<void> _checkPolicy(
|
|||||||
|
|
||||||
Future<void> _checkDprChange(
|
Future<void> _checkDprChange(
|
||||||
TestFlutterView view, List<Map<dynamic, dynamic>> registrations) async {
|
TestFlutterView view, List<Map<dynamic, dynamic>> 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 canvas = _Canvas(1, style: kRemoteViewStyleAdaptive, scale: 1);
|
||||||
final cursor = _Cursor(data, _FFI(canvas));
|
final cursor = _Cursor(data, _FFI(canvas));
|
||||||
for (final dpr in [2.0, 1.0]) {
|
for (final dpr in [2.0, 1.0]) {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// The test drives the cursor lifecycle normally owned by MouseTracker.
|
||||||
|
// ignore_for_file: invalid_use_of_protected_member
|
||||||
|
|
||||||
@TestOn('browser')
|
@TestOn('browser')
|
||||||
library;
|
library;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user