mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 14:07:28 +08:00
Filter edge swipe gesture to touch-only input (exclude mouse/trackpad)
Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
@@ -45,6 +45,7 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
// For iOS edge swipe gesture
|
// For iOS edge swipe gesture
|
||||||
double _swipeStartX = 0;
|
double _swipeStartX = 0;
|
||||||
double _swipeCurrentX = 0;
|
double _swipeCurrentX = 0;
|
||||||
|
PointerDeviceKind? _swipeDeviceKind;
|
||||||
|
|
||||||
// For web only.
|
// For web only.
|
||||||
// 'monospace' does not work on web, use Google Fonts, `??` is only for null safety.
|
// 'monospace' does not work on web, use Google Fonts, `??` is only for null safety.
|
||||||
@@ -218,23 +219,29 @@ class _TerminalPageState extends State<TerminalPage>
|
|||||||
onHorizontalDragStart: (details) {
|
onHorizontalDragStart: (details) {
|
||||||
_swipeStartX = details.globalPosition.dx;
|
_swipeStartX = details.globalPosition.dx;
|
||||||
_swipeCurrentX = details.globalPosition.dx; // Reset to start position
|
_swipeCurrentX = details.globalPosition.dx; // Reset to start position
|
||||||
|
_swipeDeviceKind = details.kind; // Track device kind
|
||||||
},
|
},
|
||||||
onHorizontalDragUpdate: (details) {
|
onHorizontalDragUpdate: (details) {
|
||||||
_swipeCurrentX = details.globalPosition.dx;
|
_swipeCurrentX = details.globalPosition.dx;
|
||||||
},
|
},
|
||||||
onHorizontalDragEnd: (details) {
|
onHorizontalDragEnd: (details) {
|
||||||
// Check if swipe started from left edge and moved right
|
// Only allow touch-based devices (not mouse/trackpad)
|
||||||
if (_swipeStartX < edgeThreshold && (_swipeCurrentX - _swipeStartX) > swipeThreshold) {
|
if (_swipeDeviceKind != null && kTouchBasedDeviceKinds.contains(_swipeDeviceKind)) {
|
||||||
// Trigger exit same as Android back button
|
// Check if swipe started from left edge and moved right
|
||||||
clientClose(sessionId, _ffi);
|
if (_swipeStartX < edgeThreshold && (_swipeCurrentX - _swipeStartX) > swipeThreshold) {
|
||||||
|
// Trigger exit same as Android back button
|
||||||
|
clientClose(sessionId, _ffi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_swipeStartX = 0;
|
_swipeStartX = 0;
|
||||||
_swipeCurrentX = 0;
|
_swipeCurrentX = 0;
|
||||||
|
_swipeDeviceKind = null;
|
||||||
},
|
},
|
||||||
onHorizontalDragCancel: () {
|
onHorizontalDragCancel: () {
|
||||||
// Reset state if gesture is interrupted
|
// Reset state if gesture is interrupted
|
||||||
_swipeStartX = 0;
|
_swipeStartX = 0;
|
||||||
_swipeCurrentX = 0;
|
_swipeCurrentX = 0;
|
||||||
|
_swipeDeviceKind = null;
|
||||||
},
|
},
|
||||||
child: scaffold,
|
child: scaffold,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user