feat: implement two-finger swipe navigation support for macOS #1
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.
Two-Finger Swipe Navigation Support for macOS
This PR implements support for two-finger swipe navigation in Electron for macOS as an opt-in feature, addressing GitHub issue electron#2683.
Changes Made
WebPreferences Integration
enableTwoFingerSwipeboolean option to WebPreferences (disabled by default)kEnableTwoFingerSwipein options_switches.hSwipe Detection Implementation
swiz_nsview_swipeWithEventmethod in electron_ns_window.mm to detect both two-finger and three-finger swipesShouldEnableTwoFingerSwipe()method in NativeWindowMac to check WebPreferences settingKey Features
Usage
Technical Implementation
The implementation follows Electron's existing architecture:
Testing
The implementation has been tested to ensure:
Files Modified
shell/common/options_switches.h- Added kEnableTwoFingerSwipe constantshell/browser/web_contents_preferences.h- Added member variable and gettershell/browser/web_contents_preferences.cc- Added parsing logic and initializationshell/browser/native_window_mac.h- Added ShouldEnableTwoFingerSwipe method declarationshell/browser/native_window_mac.mm- Implemented preference checking methodshell/browser/ui/cocoa/electron_ns_window.mm- Enhanced swipe detection logicdocs/api/structures/web-preferences.md- Added documentationLink to Devin run: https://app.devin.ai/sessions/5ef9e74c0a8844b383c4f93cab5f2fb9
Requested by: Evan (evan@iamevan.dev)
Addresses electron#2683