mirror of
https://github.com/rustdesk/rustdesk
synced 2026-04-21 13:27:19 +00:00
fix: iPad mouse down detection
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
This commit is contained in:
parent
b3f43f55c1
commit
d539bbe3de
1 changed files with 18 additions and 0 deletions
|
|
@ -1332,6 +1332,17 @@ class InputModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// iOS may emit a synthesized touch event after a real mouse click.
|
||||
/// This helper ignores touch-down events that arrive shortly after a mouse down,
|
||||
/// even when the position is far (e.g., near the top edge).
|
||||
bool shouldIgnoreTouchAfterMouse(ui.Offset pos, int nowMs) {
|
||||
if (!isIOS) return false;
|
||||
if (shouldIgnoreTouchTap(pos)) return true;
|
||||
const int kTouchAfterMouseWindowMs = 700;
|
||||
final dt = nowMs - _lastMouseDownTimeMs;
|
||||
return dt >= 0 && dt < kTouchAfterMouseWindowMs;
|
||||
}
|
||||
|
||||
void onPointDownImage(PointerDownEvent e) {
|
||||
debugPrint("onPointDownImage ${e.kind}");
|
||||
_stopFling = true;
|
||||
|
|
@ -1344,6 +1355,9 @@ class InputModel {
|
|||
// Track mouse down events for duplicate detection on iOS.
|
||||
final nowMs = DateTime.now().millisecondsSinceEpoch;
|
||||
if (e.kind == ui.PointerDeviceKind.mouse) {
|
||||
if (!isPhysicalMouse.value) {
|
||||
isPhysicalMouse.value = true;
|
||||
}
|
||||
_lastMouseDownTimeMs = nowMs;
|
||||
_lastMouseDownPos = e.position;
|
||||
}
|
||||
|
|
@ -1353,6 +1367,10 @@ class InputModel {
|
|||
}
|
||||
|
||||
if (e.kind != ui.PointerDeviceKind.mouse) {
|
||||
// Ignore duplicate touch events that follow a recent mouse click (iOS Magic Mouse issue).
|
||||
if (isPhysicalMouse.value && shouldIgnoreTouchAfterMouse(e.position, nowMs)) {
|
||||
return;
|
||||
}
|
||||
if (isPhysicalMouse.value) {
|
||||
isPhysicalMouse.value = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue