fix: android, touch mode, one finger pan, start pos (#8427)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
82bf04da81
commit
a91f244f35
@ -112,6 +112,8 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: This debounce logic is not working properly.
|
||||||
|
// If we move our finger very fast, we won't be able to detect the "oneFingerPan" event sometimes.
|
||||||
void onOneFingerStartDebounce(ScaleUpdateDetails d) {
|
void onOneFingerStartDebounce(ScaleUpdateDetails d) {
|
||||||
start(ScaleUpdateDetails d) {
|
start(ScaleUpdateDetails d) {
|
||||||
_currentState = GestureState.oneFingerPan;
|
_currentState = GestureState.oneFingerPan;
|
||||||
|
@ -69,6 +69,8 @@ class RawTouchGestureDetectorRegion extends StatefulWidget {
|
|||||||
class _RawTouchGestureDetectorRegionState
|
class _RawTouchGestureDetectorRegionState
|
||||||
extends State<RawTouchGestureDetectorRegion> {
|
extends State<RawTouchGestureDetectorRegion> {
|
||||||
Offset _cacheLongPressPosition = Offset(0, 0);
|
Offset _cacheLongPressPosition = Offset(0, 0);
|
||||||
|
// Timestamp of the last long press event.
|
||||||
|
int _cacheLongPressPositionTs = 0;
|
||||||
double _mouseScrollIntegral = 0; // mouse scroll speed controller
|
double _mouseScrollIntegral = 0; // mouse scroll speed controller
|
||||||
double _scale = 1;
|
double _scale = 1;
|
||||||
|
|
||||||
@ -151,6 +153,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
if (handleTouch) {
|
if (handleTouch) {
|
||||||
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
_cacheLongPressPosition = d.localPosition;
|
_cacheLongPressPosition = d.localPosition;
|
||||||
|
_cacheLongPressPositionTs = DateTime.now().millisecondsSinceEpoch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +236,16 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
ffi.cursorModel.trySetRemoteWindowCoords();
|
ffi.cursorModel.trySetRemoteWindowCoords();
|
||||||
}
|
}
|
||||||
|
// Workaround for the issue that the first pan event is sent a long time after the start event.
|
||||||
|
// If the time interval between the start event and the first pan event is less than 500ms,
|
||||||
|
// we consider to use the long press position as the start position.
|
||||||
|
//
|
||||||
|
// TODO: We should find a better way to send the first pan event as soon as possible.
|
||||||
|
if (DateTime.now().millisecondsSinceEpoch - _cacheLongPressPositionTs <
|
||||||
|
500) {
|
||||||
|
ffi.cursorModel
|
||||||
|
.move(_cacheLongPressPosition.dx, _cacheLongPressPosition.dy);
|
||||||
|
}
|
||||||
inputModel.sendMouse('down', MouseButtons.left);
|
inputModel.sendMouse('down', MouseButtons.left);
|
||||||
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user