fix(mobile): move the key bar out of the canvas gesture region (#17379)

* fix(mobile): keep gestures on the key bar from clicking the remote

The key bar sits inside the remote canvas's gesture region, so any tap,
double tap or long press its buttons do not take went to the canvas
recognizers: a tap between keys clicked the remote, two quick taps on a
key double-clicked it, and a long press right-clicked it, with any
latched modifier added. Wrap the bar in an opaque GestureDetector that
claims those gestures; its recognizers join the arena before the
canvas's, so they win.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkig1bcC5Xrr1uwX47b

* fix(mobile): move the key bar out of the canvas gesture region

The GestureDetector wrapper won the arena but the canvas recognizers still
saw every touch on the bar: onLongPressDown sends a left-button down to a
mobile peer before the arena decides, so a long press on the bar lost its
button-up, and the canvas double-tap recognizer kept delaying and dropping
quick key taps.

Drop the wrapper and stack the bar above the canvas instead of inside it,
so a touch on the bar never reaches the canvas recognizers. The remote
cursor and the virtual mouse move up with it and stay above the bar, as
they were inside the canvas stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkig1bcC5Xrr1uwX47b

* fix(mobile): keep the mouse-mode virtual mouse inside the canvas gesture region

Holding a virtual left/right button while another finger drags relies on
the canvas recognizer seeing both pointers: it then takes the
isSpecialHoldDragActive branch of onTwoFingerScaleUpdate. With the virtual
mouse moved above the key bar and out of the region, the recognizer saw
only the dragging finger, routed it through onOneFingerPanUpdate, and any
movement of the holding finger set blockEvents and froze the drag while the
remote button stayed down. Put FloatingMouseWidgets back where master has
it; the cursor and the touch-mode virtual mouse stay above the bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkig1bcC5Xrr1uwX47b

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RustDeskandClaude Opus 5.5 authored and GitHub committed 2026-12-04 20:11:07 +08:00
1 parent ecf60f961e
commit 0f65927e91
1 file changed
+31 -22
+31 -22
View File
@@ -566,12 +566,13 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
}
return Container(
color: MyTheme.canvasColor,
child: inputModel.isPhysicalMouse.value
? getBodyForMobile()
: RawTouchGestureDetectorRegion(
child: getBodyForMobile(),
ffi: gFFI,
),
child: withKeyHelpTools(
inputModel.isPhysicalMouse.value
? getBodyForMobile()
: RawTouchGestureDetectorRegion(
child: getBodyForMobile(),
ffi: gFFI,
)),
);
}),
),
@@ -712,6 +713,27 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
!gFFI.canvasModel.cursorEmbedded &&
!gFFI.inputModel.relativeMouseMode.value;
// The key bar sits above the canvas, outside its gesture region: a touch on the bar must not
// also reach the canvas recognizers, which would send it to the remote as a mouse event.
// The cursor and the touch-mode virtual mouse stay above the bar, as they were inside the canvas
// stack. The mouse-mode virtual mouse stays inside the region: see getBodyForMobile.
Widget withKeyHelpTools(Widget body) => Stack(children: [
Positioned.fill(child: body),
Obx(() {
final chatKeyboardRequested =
gFFI.chatModel.softKeyboardRequested.value;
return KeyHelpTools(
keyboardIsVisible: keyboardVisibilityController.isVisible &&
(_showEdit || chatKeyboardRequested),
showGestureHelp: _showGestureHelp);
}),
if (showCursorPaint) CursorPaint(widget.id),
if (gFFI.ffiModel.touchMode)
FloatingMouse(
ffi: gFFI,
),
]);
Widget getBodyForMobile() {
return Container(
color: MyTheme.canvasColor,
@@ -723,14 +745,6 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
right: 10,
child: QualityMonitor(gFFI.qualityMonitorModel),
),
Obx(() {
final chatKeyboardRequested =
gFFI.chatModel.softKeyboardRequested.value;
return KeyHelpTools(
keyboardIsVisible: keyboardVisibilityController.isVisible &&
(_showEdit || chatKeyboardRequested),
showGestureHelp: _showGestureHelp);
}),
SizedBox(
width: 0,
height: 0,
@@ -762,14 +776,9 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
).workaroundFreezeLinuxMint(),
),
];
if (showCursorPaint) {
paints.add(CursorPaint(widget.id));
}
if (gFFI.ffiModel.touchMode) {
paints.add(FloatingMouse(
ffi: gFFI,
));
} else {
// Holding a virtual button while another finger drags needs both pointers in the canvas
// recognizers (isSpecialHoldDragActive), so these stay inside the gesture region.
if (!gFFI.ffiModel.touchMode) {
paints.add(FloatingMouseWidgets(
ffi: gFFI,
));