OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 } | 793 } |
794 | 794 |
795 - (void)scrollWheel:(NSEvent*)theEvent { | 795 - (void)scrollWheel:(NSEvent*)theEvent { |
796 if (!hostedView_) | 796 if (!hostedView_) |
797 return; | 797 return; |
798 | 798 |
799 ui::ScrollEvent event(theEvent); | 799 ui::ScrollEvent event(theEvent); |
800 hostedView_->GetWidget()->OnScrollEvent(&event); | 800 hostedView_->GetWidget()->OnScrollEvent(&event); |
801 } | 801 } |
802 | 802 |
803 // Called when we get a three-finger swipe, and they're enabled in System | |
804 // Preferences. | |
805 - (void)swipeWithEvent:(NSEvent*)event { | |
806 if (!hostedView_) | |
807 return; | |
808 | |
809 // themblsha: In my testing all three-finger swipes send only a single event | |
810 // with a value of +/-1 on either axis. Diagonal swipes are not handled by | |
811 // AppKit. | |
812 | |
813 // We need to invert deltas in order to match GestureEventDetails's | |
814 // directions. | |
815 ui::GestureEventDetails swipeDetails(ui::ET_GESTURE_SWIPE, -[event deltaX], | |
816 -[event deltaY]); | |
817 swipeDetails.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); | |
818 swipeDetails.set_touch_points(3); | |
819 | |
820 gfx::PointF location = ui::EventLocationFromNative(event); | |
821 // Note this uses the default unique_touch_event_id of 0 (Swipe events do not | |
822 // 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.
| |
823 // because the three-finger swipes are instant and can't be tracked anyway. | |
824 ui::GestureEvent gestureEvent(location.x(), location.y(), | |
825 ui::EventFlagsFromNative(event), | |
826 ui::EventTimeFromNative(event), swipeDetails); | |
827 | |
828 hostedView_->GetWidget()->OnGestureEvent(&gestureEvent); | |
829 } | |
830 | |
803 - (void)quickLookWithEvent:(NSEvent*)theEvent { | 831 - (void)quickLookWithEvent:(NSEvent*)theEvent { |
804 if (!hostedView_) | 832 if (!hostedView_) |
805 return; | 833 return; |
806 | 834 |
807 const gfx::Point locationInContent = | 835 const gfx::Point locationInContent = |
808 gfx::ToFlooredPoint(ui::EventLocationFromNative(theEvent)); | 836 gfx::ToFlooredPoint(ui::EventLocationFromNative(theEvent)); |
809 views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); | 837 views::View* target = hostedView_->GetEventHandlerForPoint(locationInContent); |
810 if (!target) | 838 if (!target) |
811 return; | 839 return; |
812 | 840 |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1485 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
1458 } | 1486 } |
1459 | 1487 |
1460 - (id)accessibilityFocusedUIElement { | 1488 - (id)accessibilityFocusedUIElement { |
1461 if (!hostedView_) | 1489 if (!hostedView_) |
1462 return nil; | 1490 return nil; |
1463 return [hostedView_->GetNativeViewAccessible() accessibilityFocusedUIElement]; | 1491 return [hostedView_->GetNativeViewAccessible() accessibilityFocusedUIElement]; |
1464 } | 1492 } |
1465 | 1493 |
1466 @end | 1494 @end |
OLD | NEW |