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:
copilot-swe-agent[bot]
2026-01-30 16:40:52 +00:00
parent efb87a7348
commit c7c1672088

View File

@@ -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,
); );