Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2690573002: MacViews: Handle three-finger swipe gestures for navigation. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..26449161e10911ec4487decf2b7d5c0721cf03b7 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -800,6 +800,24 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
hostedView_->GetWidget()->OnScrollEvent(&event);
}
+// Called when we get a three-finger swipe, and they're enabled in System
tapted 2017/02/13 11:26:25 I think the pref can be set to 2-fingers or 3-fing
themblsha 2017/02/15 17:35:34 Yep. But two-finger swipes are already handled by
tapted 2017/02/15 22:25:52 ohh interesting. We'll eventually want to remove H
+// Preferences.
+- (void)swipeWithEvent:(NSEvent*)event {
tapted 2017/02/13 11:26:25 This should bail out early when hostedView_ is nul
themblsha 2017/02/15 17:35:34 Done.
+ ui::GestureEventDetails swipe_details(ui::ET_GESTURE_SWIPE, [event deltaX],
tapted 2017/02/13 11:26:24 EventTypeFromNative needs to be updated -- NSEvent
tapted 2017/02/13 11:26:25 swipe_details -> swipeDetails (This is between @fo
themblsha 2017/02/15 17:35:34 Done.
themblsha 2017/02/15 17:35:34 It's technically the same type of NSEvent that sta
tapted 2017/02/15 22:25:52 Acknowledged.
+ [event deltaY]);
+ swipe_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
+
tapted 2017/02/13 11:26:24 set_touch_points?
themblsha 2017/02/15 17:35:34 I don't think it's applicable to the instant three
tapted 2017/02/15 22:25:52 Acknowledged. (I'd also be fine with just setting
themblsha 2017/02/16 15:27:49 Ah. Okay, added setting it to `3` :-)
+ gfx::PointF location = ui::EventLocationFromNative(event);
+ ui::GestureEvent gesture_event(location.x(), location.y(),
tapted 2017/02/13 11:26:25 gestureEvent, or just |event|
themblsha 2017/02/15 17:35:34 Done.
+ [event modifierFlags],
tapted 2017/02/13 11:26:25 EventFlagsFromNative - we can't pass the Cocoa fla
themblsha 2017/02/15 17:35:34 Done.
+ ui::EventTimeFromNative(event), swipe_details);
tapted 2017/02/13 11:26:24 -[NSEvent eventNumber] is probably an appropriate
themblsha 2017/02/15 17:35:34 This throws an exception: Invalid message sent to
tapted 2017/02/15 22:25:52 Can you comment about this? (~ "Note this uses the
themblsha 2017/02/16 15:27:49 Done.
+
+ views::NativeWidgetMac::GetBridgeForNativeWindow([self window])
+ ->native_widget_mac()
+ ->GetWidget()
tapted 2017/02/13 11:26:24 hostedView_->GetWidget()
themblsha 2017/02/15 17:35:34 Done.
+ ->OnGestureEvent(&gesture_event);
+}
+
- (void)quickLookWithEvent:(NSEvent*)theEvent {
if (!hostedView_)
return;

Powered by Google App Engine
This is Rietveld 408576698