Fix touchpad right-click#1071
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRemoved explicit right-button disable from XServerScreen; InputControlsView now enables both pointer buttons on touch-down and conditionally disables them per binding. TouchpadView adds suppression for a left-click after a two-finger right-click, prevents duplicate two-finger tap handling, and tightens press/release guards tied to finger identity and enabled state. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User (touch)
participant Input as InputControlsView
participant Touch as TouchpadView
participant XSrv as XServerScreen
User->>Input: touch down / pointer events
Note over Input: enables both pointer buttons\nthen inspects ControlElement bindings
Input-->>Touch: forward touch stream (with button-enable state)
alt binding includes MOUSE_RIGHT_BUTTON
Input->>Touch: disable right button for this element
end
Touch->>Touch: handle taps\n(two-finger detection sets twoFingerTapFired,\nsuppressNextLeftTap flagged)
Touch->>XSrv: inject pointer press/release events (respecting guards)
XSrv-->>Touch: acknowledge/input consumed
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/src/main/java/com/winlator/widget/TouchpadView.java">
<violation number="1" location="app/src/main/java/com/winlator/widget/TouchpadView.java:1074">
P2: Forced release-before-press can break legitimate existing held-button state and interrupt ongoing drag/selection interactions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/com/winlator/widget/TouchpadView.java`:
- Around line 1099-1115: The delayed release Runnables in
releasePointerButtonLeft (and similarly releasePointerButtonRight) currently
close over mutable field fingerPointerButtonLeft/fingerPointerButtonRight so a
later reassignment can be cancelled by an earlier runnable; fix by capturing a
local stable token (e.g., final Finger capturedFinger =
this.fingerPointerButtonLeft or an incrementing pressId capturedPressId) inside
the method and then inside the postDelayed Runnable check that the current field
still equals capturedFinger (or that currentPressId == capturedPressId) before
performing the release and clearing the field; bail out from the Runnable if the
token does not match.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c73821ae-f178-449f-ba42-2a0d5d2506c2
📒 Files selected for processing (3)
app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.ktapp/src/main/java/com/winlator/widget/InputControlsView.javaapp/src/main/java/com/winlator/widget/TouchpadView.java
💤 Files with no reviewable changes (1)
- app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
…ns, enable dynamic right-click control Three related issues fixed: 1. Two-finger right-click tap fires a spurious left-click when the second finger lifts (numFingers drops to 1, case 1 fires). Added suppressNextLeftTap flag: set on right-click (case 2), checked and cleared on left-tap (case 1). Reset on ACTION_DOWN to prevent stale state after ACTION_CANCEL. 2. Repeated right-clicks silently fail. pressPointerButtonLeft/Right guarded with !isButtonPressed() which drops the press if the button state is stale (Pointer.buttonMask is a plain int read from UI thread without XLock). Changed to force-release any stuck button before pressing, so clicks always go through. Release functions simplified with early-return guard; isButtonPressed check moved inside the delayed runnable as a safety net. 3. showInputControls() unconditionally called setPointerButtonRightEnabled(false), killing two-finger right-click even on gamepad presets with no MOUSE_RIGHT_BUTTON binding. Removed the blanket disable. InputControlsView now dynamically checks for MOUSE_RIGHT_BUTTON bindings on ACTION_DOWN (mirroring the existing MOUSE_LEFT_BUTTON pattern) and only disables right-click when a dedicated button element exists in the profile.
976c66f to
d3688aa
Compare
Two-finger tap fired right-click in handleTsPointerUp(), then handleTsUp() also fired a left-click because the finger hadn't moved beyond tap threshold. Added twoFingerTapFired flag to suppress the spurious left-click, matching the existing doubleTapDetected pattern.
Description
This is a fix for the issue reported in the Discord here: https://discord.com/channels/1378308569287622737/1488785598658510909
Right now, using the default trackpad, right clicks often don't trigger from two-finger taps. This fixes that and also makes two finger taps work as right click unless if a right click button is created from the control editor (just like how left click works right now).
Recording
Screen_Recording_20260402_000551_GameNative.mp4
Checklist
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.CONTRIBUTING.md.Summary by cubic
Fixes unreliable touchpad right-clicks. Two-finger taps now register as right-click without stray left-clicks, and repeated clicks always register. Two-finger right-click stays enabled unless a profile defines a right-click button.
com.winlator.widget.TouchpadView: Added suppress flags to block a left-tap after a two-finger right-click in both pointer and touchscreen paths; reset on ACTION_DOWN.com.winlator.widget.TouchpadView: Force-release before pressing left/right buttons to clear stale state; safer delayed releases with early guards and finger-capture checks.app.gamenative.ui/screen/xserver/XServerScreen: Removed blanket disable of right-click.com.winlator.widget.InputControlsView: Enable both pointer buttons on touch down; disable left/right only when a control bindsMOUSE_LEFT_BUTTONorMOUSE_RIGHT_BUTTON.Written for commit bd27d50. Summary will update on new commits.
Summary by CodeRabbit