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..b477b43db4d1e2ac9dec8a9faabf3cdcc7d62ca3 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -800,6 +800,27 @@ 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; |
+ |
+ // We need to invert deltas in order to match GestureEventDetails's |
+ // directions. |
+ auto invert = [](CGFloat val) { return val * -1.; }; |
tapted
2017/02/15 22:25:53
The comment is good, but (unless I'm missing somet
themblsha
2017/02/16 15:27:49
You've opened my eyes yet again. Thanks :-)
|
+ ui::GestureEventDetails swipeDetails( |
+ ui::ET_GESTURE_SWIPE, invert([event deltaX]), invert([event deltaY])); |
+ swipeDetails.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); |
+ |
+ gfx::PointF location = ui::EventLocationFromNative(event); |
+ 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; |