fix: make context-menu double-click reliable on Linux/macOS (#24, #26, #12)#28
Open
furkanyolal wants to merge 1 commit into
Open
Conversation
On platforms where Chromium fires `contextmenu` on mouse-down (Linux, macOS), the first right-click is reserved for gesture detection and the context menu only opens on a second click. The detection for that second click required it to land within 300ms AND within the *gesture* `distanceThreshold` (10px) of the first. A normal-paced double-click easily exceeds 300ms, so the menu was repeatedly re-suppressed and users had to right-click 3-4 times to open it (diredocks#24, diredocks#26, diredocks#12). - Widen the time window to a configurable `contextMenuTimeout` (default 400ms, exposed in advanced settings) instead of the hardcoded 300ms. - Decouple the double-click distance tolerance from the gesture `distanceThreshold` (dedicated 24px constant) so minor cursor jitter between the two clicks no longer resets the sequence. - Clear the pending first-click when a real gesture starts, so a gesture's suppressed contextmenu can't be mistaken for the second click of a context-menu double-click. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When gestures are bound to the right button, opening the context menu on Linux/macOS takes 3–4 right-clicks instead of the intended double-click (#24, #26, #12).
On these platforms Chromium fires the
contextmenuevent on mouse-down, so the first right-click is necessarily reserved for gesture detection and the menu is meant to open on a second click. The detection of that second click, however, required it to land within 300 ms AND within the gesturedistanceThreshold(10 px) of the first:A normal-paced double-click easily exceeds 300 ms, so the second click falls outside the window, gets suppressed again, and
_lastClickresets to "now" — the user has to keep clicking until two happen to land < 300 ms apart. Reusing the tiny gesture threshold for the click-distance check makes it even more fragile.Fix
Keep the existing (and, on Chromium, unavoidable) double-click model, but make it reliable:
Settings.Gesture.contextMenuTimeout(default 400 ms), exposed in the advanced gesture settings so users who want a longer window can set one. This directly addresses the maintainer's note in When rocker gestures are on, right clicking on webpages requires double right clicking. #12/Context menu appears after every gesture #18 about adding an option to control this behavior.distanceThresholdvia a dedicated, more generous constant (24 px), so minor cursor jitter between the two clicks no longer resets the sequence.contextmenucan't be mistaken for the second click of a context-menu double-click.No behavioural change on Windows (where
contextmenufires on mouse-up and single-click already works) — only the non-Windows double-click path and its new tunable are affected. Defaults are backward-compatible.Testing
Built with
npm run distand loaded unpacked in Brave 1.91.171 / Chromium 149 on KDE Plasma 6.6 Wayland:Note
This does not (and cannot) provide single-right-click context menus with right-button gestures on Chromium — that requires the menu to fire on mouse-up, which Chromium does not expose to extensions (see chromium issue 41029299). This PR only makes the existing double-click compromise dependable.