mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 08:23:01 +08:00
Merge pull request #5121 from dignow/fix/android_mouse_mode
Fix/android mouse mode
This commit is contained in:
commit
71ffa21db0
@ -1350,7 +1350,7 @@ class LastWindowPosition {
|
|||||||
return LastWindowPosition(m["width"], m["height"], m["offsetWidth"],
|
return LastWindowPosition(m["width"], m["height"], m["offsetWidth"],
|
||||||
m["offsetHeight"], m["isMaximized"]);
|
m["offsetHeight"], m["isMaximized"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrintStack(label: e.toString());
|
debugPrintStack(label: 'Failed to load LastWindowPosition "$content" ${e.toString()}');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,8 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
|||||||
_TapTracker? _firstTap;
|
_TapTracker? _firstTap;
|
||||||
_TapTracker? _secondTap;
|
_TapTracker? _secondTap;
|
||||||
|
|
||||||
|
PointerDownEvent? _lastPointerDownEvent;
|
||||||
|
|
||||||
final Map<int, _TapTracker> _trackers = <int, _TapTracker>{};
|
final Map<int, _TapTracker> _trackers = <int, _TapTracker>{};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -238,6 +240,7 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
|||||||
gestureSettings: gestureSettings,
|
gestureSettings: gestureSettings,
|
||||||
);
|
);
|
||||||
_trackers[event.pointer] = tracker;
|
_trackers[event.pointer] = tracker;
|
||||||
|
_lastPointerDownEvent = event;
|
||||||
tracker.startTrackingPointer(_handleEvent, event.transform);
|
tracker.startTrackingPointer(_handleEvent, event.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +251,11 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
|||||||
_registerFirstTap(tracker);
|
_registerFirstTap(tracker);
|
||||||
} else if (_secondTap != null) {
|
} else if (_secondTap != null) {
|
||||||
if (event.pointer == _secondTap!.pointer) {
|
if (event.pointer == _secondTap!.pointer) {
|
||||||
if (onHoldDragEnd != null) onHoldDragEnd!(DragEndDetails());
|
if (onHoldDragEnd != null) {
|
||||||
|
onHoldDragEnd!(DragEndDetails());
|
||||||
|
_secondTap = null;
|
||||||
|
_isStart = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_reject(tracker);
|
_reject(tracker);
|
||||||
@ -303,7 +310,11 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer {
|
|||||||
_secondTap?.entry.resolve(GestureDisposition.accepted);
|
_secondTap?.entry.resolve(GestureDisposition.accepted);
|
||||||
_isStart = true;
|
_isStart = true;
|
||||||
// TODO start details
|
// TODO start details
|
||||||
if (onHoldDragStart != null) onHoldDragStart!(DragStartDetails());
|
if (onHoldDragStart != null) {
|
||||||
|
onHoldDragStart!(DragStartDetails(
|
||||||
|
kind: _lastPointerDownEvent?.kind,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _reject(_TapTracker tracker) {
|
void _reject(_TapTracker tracker) {
|
||||||
@ -435,6 +446,8 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer {
|
|||||||
Timer? _firstTapTimer;
|
Timer? _firstTapTimer;
|
||||||
_TapTracker? _firstTap;
|
_TapTracker? _firstTap;
|
||||||
|
|
||||||
|
PointerDownEvent? _lastPointerDownEvent;
|
||||||
|
|
||||||
var _isStart = false;
|
var _isStart = false;
|
||||||
|
|
||||||
final Set<int> _upTap = {};
|
final Set<int> _upTap = {};
|
||||||
@ -476,6 +489,7 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer {
|
|||||||
} else {
|
} else {
|
||||||
// first tap
|
// first tap
|
||||||
_isStart = true;
|
_isStart = true;
|
||||||
|
_lastPointerDownEvent = event;
|
||||||
_startFirstTapDownTimer();
|
_startFirstTapDownTimer();
|
||||||
}
|
}
|
||||||
_trackTap(event);
|
_trackTap(event);
|
||||||
@ -591,7 +605,11 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer {
|
|||||||
|
|
||||||
void _resolve() {
|
void _resolve() {
|
||||||
// TODO tap down details
|
// TODO tap down details
|
||||||
if (onDoubleFinerTap != null) onDoubleFinerTap!(TapDownDetails());
|
if (onDoubleFinerTap != null) {
|
||||||
|
onDoubleFinerTap!(TapDownDetails(
|
||||||
|
kind: _lastPointerDownEvent?.kind,
|
||||||
|
));
|
||||||
|
}
|
||||||
_trackers.forEach((key, value) {
|
_trackers.forEach((key, value) {
|
||||||
value.entry.resolve(GestureDisposition.accepted);
|
value.entry.resolve(GestureDisposition.accepted);
|
||||||
});
|
});
|
||||||
|
@ -93,8 +93,8 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
}
|
}
|
||||||
if (handleTouch) {
|
if (handleTouch) {
|
||||||
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
|
inputModel.tapDown(MouseButtons.left);
|
||||||
}
|
}
|
||||||
inputModel.tapDown(MouseButtons.left);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTapUp(TapUpDetails d) {
|
onTapUp(TapUpDetails d) {
|
||||||
@ -103,8 +103,15 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
}
|
}
|
||||||
if (handleTouch) {
|
if (handleTouch) {
|
||||||
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
|
||||||
|
inputModel.tapUp(MouseButtons.left);
|
||||||
}
|
}
|
||||||
inputModel.tapUp(MouseButtons.left);
|
}
|
||||||
|
|
||||||
|
onTap() {
|
||||||
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inputModel.tap(MouseButtons.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDoubleTapDown(TapDownDetails d) {
|
onDoubleTapDown(TapDownDetails d) {
|
||||||
@ -136,6 +143,15 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLongPressUp() {
|
||||||
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handleTouch) {
|
||||||
|
inputModel.tapUp(MouseButtons.left);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// for mobiles
|
// for mobiles
|
||||||
onLongPress() {
|
onLongPress() {
|
||||||
if (lastDeviceKind != PointerDeviceKind.touch) {
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
@ -151,12 +167,20 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
inputModel.tap(MouseButtons.right);
|
inputModel.tap(MouseButtons.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDoubleFinerTapDown(TapDownDetails d) {
|
||||||
|
lastDeviceKind = d.kind;
|
||||||
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// ignore for desktop and mobile
|
||||||
|
}
|
||||||
|
|
||||||
onDoubleFinerTap(TapDownDetails d) {
|
onDoubleFinerTap(TapDownDetails d) {
|
||||||
lastDeviceKind = d.kind;
|
lastDeviceKind = d.kind;
|
||||||
if (lastDeviceKind != PointerDeviceKind.touch) {
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDesktop || !handleTouch) {
|
if (isDesktop || !ffiModel.touchMode) {
|
||||||
inputModel.tap(MouseButtons.right);
|
inputModel.tap(MouseButtons.right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,12 +245,16 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
if (lastDeviceKind != PointerDeviceKind.touch) {
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (handleTouch) {
|
inputModel.sendMouse('up', MouseButtons.left);
|
||||||
inputModel.sendMouse('up', MouseButtons.left);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale + pan event
|
// scale + pan event
|
||||||
|
onTwoFingerScaleStart(ScaleStartDetails d) {
|
||||||
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onTwoFingerScaleUpdate(ScaleUpdateDetails d) {
|
onTwoFingerScaleUpdate(ScaleUpdateDetails d) {
|
||||||
if (lastDeviceKind != PointerDeviceKind.touch) {
|
if (lastDeviceKind != PointerDeviceKind.touch) {
|
||||||
return;
|
return;
|
||||||
@ -291,7 +319,8 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
() => TapGestureRecognizer(), (instance) {
|
() => TapGestureRecognizer(), (instance) {
|
||||||
instance
|
instance
|
||||||
..onTapDown = onTapDown
|
..onTapDown = onTapDown
|
||||||
..onTapUp = onTapUp;
|
..onTapUp = onTapUp
|
||||||
|
..onTap = onTap;
|
||||||
}),
|
}),
|
||||||
DoubleTapGestureRecognizer:
|
DoubleTapGestureRecognizer:
|
||||||
GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>(
|
GestureRecognizerFactoryWithHandlers<DoubleTapGestureRecognizer>(
|
||||||
@ -305,6 +334,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
() => LongPressGestureRecognizer(), (instance) {
|
() => LongPressGestureRecognizer(), (instance) {
|
||||||
instance
|
instance
|
||||||
..onLongPressDown = onLongPressDown
|
..onLongPressDown = onLongPressDown
|
||||||
|
..onLongPressUp = onLongPressUp
|
||||||
..onLongPress = onLongPress;
|
..onLongPress = onLongPress;
|
||||||
}),
|
}),
|
||||||
// Customized
|
// Customized
|
||||||
@ -319,7 +349,9 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
DoubleFinerTapGestureRecognizer:
|
DoubleFinerTapGestureRecognizer:
|
||||||
GestureRecognizerFactoryWithHandlers<DoubleFinerTapGestureRecognizer>(
|
GestureRecognizerFactoryWithHandlers<DoubleFinerTapGestureRecognizer>(
|
||||||
() => DoubleFinerTapGestureRecognizer(), (instance) {
|
() => DoubleFinerTapGestureRecognizer(), (instance) {
|
||||||
instance.onDoubleFinerTap = onDoubleFinerTap;
|
instance
|
||||||
|
..onDoubleFinerTap = onDoubleFinerTap
|
||||||
|
..onDoubleFinerTapDown = onDoubleFinerTapDown;
|
||||||
}),
|
}),
|
||||||
CustomTouchGestureRecognizer:
|
CustomTouchGestureRecognizer:
|
||||||
GestureRecognizerFactoryWithHandlers<CustomTouchGestureRecognizer>(
|
GestureRecognizerFactoryWithHandlers<CustomTouchGestureRecognizer>(
|
||||||
@ -329,6 +361,7 @@ class _RawTouchGestureDetectorRegionState
|
|||||||
instance
|
instance
|
||||||
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
..onOneFingerPanUpdate = onOneFingerPanUpdate
|
||||||
..onOneFingerPanEnd = onOneFingerPanEnd
|
..onOneFingerPanEnd = onOneFingerPanEnd
|
||||||
|
..onTwoFingerScaleStart = onTwoFingerScaleStart
|
||||||
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
||||||
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
||||||
..onThreeFingerVerticalDragUpdate = onThreeFingerVerticalDragUpdate;
|
..onThreeFingerVerticalDragUpdate = onThreeFingerVerticalDragUpdate;
|
||||||
|
Loading…
Reference in New Issue
Block a user