From c8cd10b6de80f40580d93ba78989aa4aed293529 Mon Sep 17 00:00:00 2001 From: dignow Date: Wed, 28 Jun 2023 22:35:21 +0800 Subject: [PATCH 1/3] min scroll, 0.1 thread Signed-off-by: dignow --- flutter/lib/models/input_model.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 640c4d79b..e32afa3ab 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -336,6 +336,14 @@ class InputModel { _trackpadLastDelta = delta; var x = delta.dx.toInt(); var y = delta.dy.toInt(); + if (x == 0 && y == 0) { + final thr = 0.1; + if (delta.dx.abs() > delta.dy.abs()) { + x = delta.dx > thr ? 1 : (delta.dx < -thr ? -1 : 0); + } else { + y = delta.dy > thr ? 1 : (delta.dy < -thr ? -1 : 0); + } + } if (x != 0 || y != 0) { bind.sessionSendMouse( sessionId: sessionId, From 8deaf8807b2e0ddc2ae7fbda21cb7c4c237438d0 Mon Sep 17 00:00:00 2001 From: dignow Date: Wed, 28 Jun 2023 23:00:29 +0800 Subject: [PATCH 2/3] touchpad, linux as the controlled side, better control Signed-off-by: dignow --- flutter/lib/models/input_model.dart | 30 ++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index e32afa3ab..6960c1a61 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -51,6 +51,9 @@ class InputModel { var _fling = false; Timer? _flingTimer; final _flingBaseDelay = 30; + // trackpad, peer linux + final _trackpadSpeed = 0.06; + var _trackpadScrollUnsent = Offset.zero; // mouse final isPhysicalMouse = false.obs; @@ -332,16 +335,24 @@ class InputModel { // https://docs.flutter.dev/release/breaking-changes/trackpad-gestures // TODO(support zoom in/out) void onPointerPanZoomUpdate(PointerPanZoomUpdateEvent e) { - final delta = e.panDelta; + var delta = e.panDelta; _trackpadLastDelta = delta; + var x = delta.dx.toInt(); var y = delta.dy.toInt(); - if (x == 0 && y == 0) { - final thr = 0.1; - if (delta.dx.abs() > delta.dy.abs()) { - x = delta.dx > thr ? 1 : (delta.dx < -thr ? -1 : 0); - } else { - y = delta.dy > thr ? 1 : (delta.dy < -thr ? -1 : 0); + if (parent.target?.ffiModel.pi.platform == kPeerPlatformLinux) { + _trackpadScrollUnsent += (delta * _trackpadSpeed); + x = _trackpadScrollUnsent.dx.truncate(); + y = _trackpadScrollUnsent.dy.truncate(); + _trackpadScrollUnsent -= Offset(x.toDouble(), y.toDouble()); + } else { + if (x == 0 && y == 0) { + final thr = 0.1; + if (delta.dx.abs() > delta.dy.abs()) { + x = delta.dx > thr ? 1 : (delta.dx < -thr ? -1 : 0); + } else { + y = delta.dy > thr ? 1 : (delta.dy < -thr ? -1 : 0); + } } } if (x != 0 || y != 0) { @@ -370,6 +381,11 @@ class InputModel { // Try set delta (x,y) and delay. var dx = x.toInt(); var dy = y.toInt(); + if (parent.target?.ffiModel.pi.platform == kPeerPlatformLinux) { + dx = (x * _trackpadSpeed).toInt(); + dy = (y * _trackpadSpeed).toInt(); + } + var delay = _flingBaseDelay; if (dx == 0 && dy == 0) { From 99a825850cb83285a44e15a296f3806ca21de829 Mon Sep 17 00:00:00 2001 From: dignow Date: Wed, 28 Jun 2023 23:06:01 +0800 Subject: [PATCH 3/3] trivial change Signed-off-by: dignow --- flutter/lib/models/input_model.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter/lib/models/input_model.dart b/flutter/lib/models/input_model.dart index 6960c1a61..e7ce5c585 100644 --- a/flutter/lib/models/input_model.dart +++ b/flutter/lib/models/input_model.dart @@ -335,7 +335,7 @@ class InputModel { // https://docs.flutter.dev/release/breaking-changes/trackpad-gestures // TODO(support zoom in/out) void onPointerPanZoomUpdate(PointerPanZoomUpdateEvent e) { - var delta = e.panDelta; + final delta = e.panDelta; _trackpadLastDelta = delta; var x = delta.dx.toInt();