From 3b036d2015b9fd886e2df0d56bac58dc08b49f43 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 23 Sep 2026 13:08:39 +0800 Subject: [PATCH] cursor: hold a native cursor to 512 pixels a side A native cursor could be registered up to 1024 pixels a side, four MiB of pixels each, which with sixteen kept made 64 MiB at worst. The largest cursor a system shows is 256 pixels (Windows' largest pointer size), so a raster twice that is shown no larger: the cursor is drawn smaller rather than rejected, and sixteen kept come to 16 MiB at most. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --- flutter/lib/models/model.dart | 5 +++-- flutter/test/cursor_size_test.dart | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 21c1d7c5f..6613e659c 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -2853,8 +2853,9 @@ class CanvasModel with ChangeNotifier { // data for cursor class CursorData { - // At most 4 MiB of RGBA, including Linux's square cursor padding. - static const _maxRasterSize = 1024; + // At most 1 MiB of RGBA, including Linux's square cursor padding: twice the largest + // accessibility cursor, beyond which a cursor is shown smaller rather than larger. + static const _maxRasterSize = 512; final String peerId; final String id; diff --git a/flutter/test/cursor_size_test.dart b/flutter/test/cursor_size_test.dart index 5182047f0..5b0e52caf 100644 --- a/flutter/test/cursor_size_test.dart +++ b/flutter/test/cursor_size_test.dart @@ -110,7 +110,7 @@ void main() { ((1, 64), 0.25, (1, 16)), ((8, 8), 0.5, (12, 12)), ((4, 64), 1.0, (4, 64)), - ((1, 512), 10.0, (2, 1024)), + ((1, 512), 10.0, (1, 512)), ]) { test('native cursor size $scenario', () => _checkSize(scenario, registrations)); @@ -268,7 +268,7 @@ Future _checkRasterTransitions( Future _checkResizeLimits( (int, int) size, List> registrations) async { - const maxSide = 1024; + const maxSide = 512; const sourceLongEdge = 30; const validScale = maxSide / sourceLongEdge; final ffi = _FFI(_Canvas(kRemoteViewStyleAdaptive));