Chromium Code Reviews| Index: ui/views/cocoa/bridged_content_view.mm |
| diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
| index b47f522dd7c759f2f1450c06c5eb9b544bfe0806..e039afb662d59266fef2213ec800932045ca90ee 100644 |
| --- a/ui/views/cocoa/bridged_content_view.mm |
| +++ b/ui/views/cocoa/bridged_content_view.mm |
| @@ -800,6 +800,34 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { |
| hostedView_->GetWidget()->OnScrollEvent(&event); |
| } |
| +// Called when we get a three-finger swipe, and they're enabled in System |
| +// Preferences. |
| +- (void)swipeWithEvent:(NSEvent*)event { |
| + if (!hostedView_) |
| + return; |
| + |
| + // themblsha: In my testing all three-finger swipes send only a single event |
| + // with a value of +/-1 on either axis. Diagonal swipes are not handled by |
| + // AppKit. |
| + |
| + // We need to invert deltas in order to match GestureEventDetails's |
| + // directions. |
| + ui::GestureEventDetails swipeDetails(ui::ET_GESTURE_SWIPE, -[event deltaX], |
| + -[event deltaY]); |
| + swipeDetails.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); |
| + swipeDetails.set_touch_points(3); |
| + |
| + gfx::PointF location = ui::EventLocationFromNative(event); |
| + // Note this uses the default unique_touch_event_id of 0 (Swipe events do not |
| + // support -[NSEvent eventNumber]. This doesn't seem like a real omission |
|
tapted
2017/02/20 23:14:21
nit: add closing paren: "... do not support -[NSEv
themblsha
2017/02/21 13:00:51
Done.
|
| + // because the three-finger swipes are instant and can't be tracked anyway. |
| + ui::GestureEvent gestureEvent(location.x(), location.y(), |
| + ui::EventFlagsFromNative(event), |
| + ui::EventTimeFromNative(event), swipeDetails); |
| + |
| + hostedView_->GetWidget()->OnGestureEvent(&gestureEvent); |
| +} |
| + |
| - (void)quickLookWithEvent:(NSEvent*)theEvent { |
| if (!hostedView_) |
| return; |