Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: Expose 3-finger swipe events in browser-window #4843

Merged
merged 2 commits into from
Mar 31, 2016

Conversation

jwheare
Copy link
Contributor

@jwheare jwheare commented Mar 18, 2016

This adds a new swipe event to browser-window for 3-finger trackpad swipes on OS X.
#4181 added support for 2-finger scroll events on OS X, which allow apps to handle some forms of back/forward navigation. However, OS X also exposes a swipeWithEvent method on NSResponder for 3-finger swipes, and it's possible to set these as the "Swipe between pages" gesture. These swipes are only directional, with no velocity, so are easily exposed as one-off events. They will only fire if the option is set in System Preferences to Swipe with two or three fingers or Swipe with three fingers

image

@zcbenz
Copy link
Contributor

zcbenz commented Mar 21, 2016

I think we should probably add just one swipe event and pass deltaX and deltaY as parameters.

@@ -267,6 +267,18 @@ - (void)setEnableLargerThanScreen:(bool)enable {

// NSWindow overrides.

- (void)swipeWithEvent:(NSEvent *)event {
if (event.deltaY == 1.0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use 2 spaces as indention.

@jwheare
Copy link
Contributor Author

jwheare commented Mar 21, 2016

Given the deltas will only ever arrive in 4 combinations, should the API just expose a single direction string instead of the raw deltas?

@jwheare
Copy link
Contributor Author

jwheare commented Mar 21, 2016

I started rewriting this PR to expose the deltas in the API, then got annoyed with having to reimplement the delta checking at the application level, and thinking about everyone else who would have to do the same. I suspect optimising for a more intuitive API vs exposing the underlying mechanism makes more sense in this case.

That said, I agree with collapsing 4 distinct events down to one event with an enum argument; the main reason I didn't initially was to avoid dealing with passing around arguments in the internals.

@jwheare
Copy link
Contributor Author

jwheare commented Mar 23, 2016

I pushed a version with a single direction argument, but I have one with deltas in a separate local branch that I can push instead if you'd prefer.

@zcbenz
Copy link
Contributor

zcbenz commented Mar 31, 2016

I'm good with a single direction argument, thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants