@@ -345,8 +345,11 @@ class InputModel {
345345 var _fling = false ;
346346 Timer ? _flingTimer;
347347 final _flingBaseDelay = 30 ;
348- // trackpad, peer linux
349- final _trackpadSpeed = 0.06 ;
348+ final _trackpadAdjustPeerLinux = 0.06 ;
349+ // This is an experience value.
350+ final _trackpadAdjustMacToWin = 2.50 ;
351+ int _trackpadSpeed = kDefaultTrackpadSpeed;
352+ double _trackpadSpeedInner = kDefaultTrackpadSpeed / 100.0 ;
350353 var _trackpadScrollUnsent = Offset .zero;
351354
352355 var _lastScale = 1.0 ;
@@ -370,6 +373,7 @@ class InputModel {
370373 bool get isViewOnly => parent.target! .ffiModel.viewOnly;
371374 double get devicePixelRatio => parent.target! .canvasModel.devicePixelRatio;
372375 bool get isViewCamera => parent.target! .connType == ConnType .viewCamera;
376+ int get trackpadSpeed => _trackpadSpeed;
373377
374378 InputModel (this .parent) {
375379 sessionId = parent.target! .sessionId;
@@ -385,6 +389,28 @@ class InputModel {
385389 }
386390 }
387391
392+ /// Updates the trackpad speed based on the session value.
393+ ///
394+ /// The expected format of the retrieved value is a string that can be parsed into a double.
395+ /// If parsing fails or the value is out of bounds (less than `kMinTrackpadSpeed` or greater
396+ /// than `kMaxTrackpadSpeed` ), the trackpad speed is reset to the default
397+ /// value (`kDefaultTrackpadSpeed` ).
398+ ///
399+ /// Bounds:
400+ /// - Minimum: `kMinTrackpadSpeed`
401+ /// - Maximum: `kMaxTrackpadSpeed`
402+ /// - Default: `kDefaultTrackpadSpeed`
403+ Future <void > updateTrackpadSpeed () async {
404+ _trackpadSpeed =
405+ (await bind.sessionGetTrackpadSpeed (sessionId: sessionId) ??
406+ kDefaultTrackpadSpeed);
407+ if (_trackpadSpeed < kMinTrackpadSpeed ||
408+ _trackpadSpeed > kMaxTrackpadSpeed) {
409+ _trackpadSpeed = kDefaultTrackpadSpeed;
410+ }
411+ _trackpadSpeedInner = _trackpadSpeed / 100.0 ;
412+ }
413+
388414 void handleKeyDownEventModifiers (KeyEvent e) {
389415 KeyUpEvent upEvent (e) => KeyUpEvent (
390416 physicalKey: e.physicalKey,
@@ -888,13 +914,16 @@ class InputModel {
888914 }
889915 }
890916
891- final delta = e.panDelta;
917+ var delta = e.panDelta * _trackpadSpeedInner;
918+ if (isMacOS && peerPlatform == kPeerPlatformWindows) {
919+ delta *= _trackpadAdjustMacToWin;
920+ }
892921 _trackpadLastDelta = delta;
893922
894923 var x = delta.dx.toInt ();
895924 var y = delta.dy.toInt ();
896925 if (peerPlatform == kPeerPlatformLinux) {
897- _trackpadScrollUnsent += (delta * _trackpadSpeed );
926+ _trackpadScrollUnsent += (delta * _trackpadAdjustPeerLinux );
898927 x = _trackpadScrollUnsent.dx.truncate ();
899928 y = _trackpadScrollUnsent.dy.truncate ();
900929 _trackpadScrollUnsent -= Offset (x.toDouble (), y.toDouble ());
@@ -942,8 +971,8 @@ class InputModel {
942971 var dx = x.toInt ();
943972 var dy = y.toInt ();
944973 if (parent.target? .ffiModel.pi.platform == kPeerPlatformLinux) {
945- dx = (x * _trackpadSpeed ).toInt ();
946- dy = (y * _trackpadSpeed ).toInt ();
974+ dx = (x * _trackpadAdjustPeerLinux ).toInt ();
975+ dy = (y * _trackpadAdjustPeerLinux ).toInt ();
947976 }
948977
949978 var delay = _flingBaseDelay;
@@ -989,7 +1018,10 @@ class InputModel {
9891018 _stopFling = false ;
9901019
9911020 // 2.0 is an experience value
992- double minFlingValue = 2.0 ;
1021+ double minFlingValue = 2.0 * _trackpadSpeedInner;
1022+ if (isMacOS && peerPlatform == kPeerPlatformWindows) {
1023+ minFlingValue *= _trackpadAdjustMacToWin;
1024+ }
9931025 if (_trackpadLastDelta.dx.abs () > minFlingValue ||
9941026 _trackpadLastDelta.dy.abs () > minFlingValue) {
9951027 _fling = true ;
0 commit comments