Skip to content

Fix virtual joysticks triggering pinch-to-zoom on map#14396

Open
DonLakeFlyer wants to merge 1 commit into
mavlink:masterfrom
DonLakeFlyer:fix-virtual-joystick-pinch
Open

Fix virtual joysticks triggering pinch-to-zoom on map#14396
DonLakeFlyer wants to merge 1 commit into
mavlink:masterfrom
DonLakeFlyer:fix-virtual-joystick-pinch

Conversation

@DonLakeFlyer
Copy link
Copy Markdown
Collaborator

Fixes #13450

Problem

When both thumbs are on the virtual joysticks simultaneously on mobile, the map's PinchHandler steals the touch grabs from the joystick MultiPointTouchArea items and interprets them as a pinch-to-zoom gesture.

Root Cause

The PinchHandler in FlightMap.qml used the default grabPermissions which includes CanTakeOverFromItems. This allows it to steal exclusive grabs that MultiPointTouchArea (an Item-based touch handler) already holds on its touch points.

Fix

Set grabPermissions: PointerHandler.CanTakeOverFromHandlersOfDifferentType on the PinchHandler. This prevents it from stealing grabs from Items (like MultiPointTouchArea in the joystick pads) while still allowing normal pinch-to-zoom when fingers land directly on the map.

Copilot AI review requested due to automatic review settings May 17, 2026 16:11

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.45%. Comparing base (f29efd3) to head (aa55176).
⚠️ Report is 13 commits behind head on master.

❌ Your project check has failed because the head coverage (25.45%) is below the target coverage (30.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14396      +/-   ##
==========================================
- Coverage   25.47%   25.45%   -0.02%     
==========================================
  Files         769      769              
  Lines       65912    66244     +332     
  Branches    30495    30640     +145     
==========================================
+ Hits        16788    16863      +75     
- Misses      37285    37410     +125     
- Partials    11839    11971     +132     
Flag Coverage Δ
unittests 25.45% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 29 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c64a14...aa55176. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/FlightMap/FlightMap.qml:193

  • When a drag is converted into a pinch, dragActive is cleared without emitting mapPanStop(). FlyViewMap.qml relies on the start/stop pair to restart panRecenterTimer; after a user pans and then adds a second finger, vehicle tracking can remain disabled indefinitely because the final release takes the pinchActive path and never sends the stop signal.
                    pinchActive = true
                    wasMultiTouch = true
                    dragActive = false
                    pinchStartDist = pinchDistance()

src/FlightMap/FlightMap.qml:203

  • The new pinch zoom path no longer clamps the computed zoom level to a non-negative value. Pinching inward can drive pinchStartZoom + Math.log2(scale) below zero (or to -Infinity if the distance collapses), unlike the removed PinchHandler and the WheelHandler path, and that invalid zoom can also be persisted through flightMapZoom.
                if (pinchStartDist > 0) {
                    let scale = currentDist / pinchStartDist
                    _map.zoomLevel = pinchStartZoom + Math.log2(scale)

Comment on lines +138 to 140
// Pinch-to-zoom is also handled here rather than via PinchHandler to prevent the handler from stealing
// touch grabs from items above (e.g. virtual joystick pads). See GitHub issue #13450.
MultiPointTouchArea {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to test this on my laptop...

Restrict the map's PinchHandler grabPermissions so it cannot steal
touch grabs from MultiPointTouchArea items (the joystick thumb pads).
Previously, when both thumbs were on the virtual joysticks simultaneously,
the PinchHandler's default CanTakeOverFromItems permission allowed it to
interpret the two touch points as a pinch gesture and zoom the map instead
of letting the joysticks operate independently.

Fixes mavlink#13450
@DonLakeFlyer DonLakeFlyer force-pushed the fix-virtual-joystick-pinch branch from eeb22e2 to aa55176 Compare May 17, 2026 16:55
@github-actions
Copy link
Copy Markdown
Contributor

Build Results

Platform Status

Platform Status Details
Linux Passed View
Windows Passed View
MacOS Passed View
Android Passed View

All builds passed.

Pre-commit

Check Status Details
pre-commit Failed (non-blocking) View

Pre-commit hooks: 4 passed, 45 failed, 7 skipped.

Test Results

linux-coverage: 90 passed, 0 skipped
Total: 90 passed, 0 skipped

Code Coverage

Coverage: 59.4%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 216.88 MB
QGroundControl-aarch64 176.78 MB
QGroundControl-installer-AMD64 134.71 MB
QGroundControl-installer-AMD64-ARM64 77.33 MB
QGroundControl-installer-ARM64 106.05 MB
QGroundControl-linux 335.18 MB
QGroundControl-mac 187.14 MB
QGroundControl-windows 187.17 MB
QGroundControl-x86_64 171.96 MB
No baseline available for comparison

Updated: 2026-05-17 17:33:50 UTC • Triggered by: Android

@DonLakeFlyer
Copy link
Copy Markdown
Collaborator Author

Need to test this more on laptops...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtual Joysticks cannot have two fingers touching

2 participants