fix: prevent context menu from dismissing on trackpad press release#58
Open
TigerInYourDream wants to merge 3 commits intomainfrom
Open
fix: prevent context menu from dismissing on trackpad press release#58TigerInYourDream wants to merge 3 commits intomainfrom
TigerInYourDream wants to merge 3 commits intomainfrom
Conversation
Track the opening gesture (digit_id + capture_time) when showing a context menu, and consume the corresponding FingerUp event instead of treating it as a "click outside" dismissal. Fixes #57
The actual root cause of the trackpad press dismissal was FingerScroll(0,0): macOS generates a zero-scroll event on two-finger press, which the menu's unconditional `Hit::FingerScroll(_) => true` treated as a close trigger. - Only close on FingerScroll when scroll delta is non-zero - Restore capture_time field in ContextMenuOpenGesture for precise gesture matching (digit_id + capture_time from Makepad capture chain) Fixes #57
Keep function signatures and call sites in their original horizontal style to minimize diff noise in the PR.
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.
Summary
Fixes #57
On macOS trackpad, right-clicking via two-finger press caused the context menu to flash and immediately disappear. This affected both the room context menu and the message context menu.
Root Cause
macOS trackpad generates a
FingerScroll(0, 0)event on two-finger press. Both menus hadHit::FingerScroll(_) => truewhich unconditionally closed on any scroll event, including zero-scroll.Fix (two layers)
Layer 1 — FingerScroll zero-scroll filter (direct fix):
Layer 2 — ContextMenuOpenGesture (defense-in-depth):
Tracks the
digit_id+capture_timeof the gesture that opened the menu. If aFingerUparrives matching this gesture, it's consumed instead of treated as "click outside". This protects against edge cases where:FingerUplands outsidemain_content)The
capture_timematching is verified correct via Makepad source:FingerDown.timeis stored ascapture.timeduringcapture_digit(), then read back asFingerUp.capture_time.Changes
src/home/mod.rs—ContextMenuOpenGesturestruct (digit_id + capture_time) andconsume_context_menu_opening_finger_up()shared utilitysrc/home/room_context_menu.rs— Track opening gesture, filter zero-scrollFingerScrollsrc/home/new_message_context_menu.rs— Same fix for message context menusrc/home/rooms_list_entry.rs— PassContextMenuOpenGestureinSecondaryClickedactionsrc/home/rooms_list.rs— Forward gesture throughOpenRoomContextMenuactionsrc/home/room_screen.rs— Pass gesture throughOpenMessageContextMenuactionsrc/app.rs— Forward gesture toshow()callsTest plan