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 #include "ui/events/event_utils.h" | 5 #include "ui/events/event_utils.h" |
6 | 6 |
7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "base/mac/mac_util.h" | |
10 #import "base/mac/sdk_forward_declarations.h" | |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "ui/events/cocoa/cocoa_event_utils.h" | 14 #include "ui/events/cocoa/cocoa_event_utils.h" |
13 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
14 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 16 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
15 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
16 #include "ui/gfx/vector2d.h" | 18 #include "ui/gfx/vector2d.h" |
17 | 19 |
18 namespace ui { | 20 namespace ui { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 return EF_RIGHT_MOUSE_BUTTON; | 125 return EF_RIGHT_MOUSE_BUTTON; |
124 case NSOtherMouseDown: | 126 case NSOtherMouseDown: |
125 case NSOtherMouseUp: | 127 case NSOtherMouseUp: |
126 case NSOtherMouseDragged: | 128 case NSOtherMouseDragged: |
127 return EF_MIDDLE_MOUSE_BUTTON; | 129 return EF_MIDDLE_MOUSE_BUTTON; |
128 } | 130 } |
129 return 0; | 131 return 0; |
130 } | 132 } |
131 | 133 |
132 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& event) { | 134 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& event) { |
133 // Empirically, a value of 0.1 is typical for one mousewheel click. Positive | 135 if (base::mac::IsOSLionOrLater() && [event hasPreciseScrollingDeltas]) { |
134 // values when scrolling up or to the left. Scrolling quickly results in a | 136 return gfx::Vector2d([event scrollingDeltaX], [event scrollingDeltaY]); |
Andre
2014/08/29 23:31:34
Scrolling feels pretty good on Magic Mouse without
tapted
2014/09/02 09:10:25
nit: It might be worth documenting what the number
Andre
2014/09/02 17:05:05
Done.
| |
135 // higher delta per click, up to about 15.0. (Quartz documentation suggests | 137 } else { |
136 // +/-10). | 138 // Empirically, a value of 0.1 is typical for one mousewheel click. Positive |
137 // Multiply by 1000 to vaguely approximate WHEEL_DELTA on Windows (120). | 139 // values when scrolling up or to the left. Scrolling quickly results in a |
138 const CGFloat kWheelDeltaMultiplier = 1000; | 140 // higher delta per click, up to about 15.0. (Quartz documentation suggests |
139 return gfx::Vector2d(kWheelDeltaMultiplier * [event deltaX], | 141 // +/-10). |
140 kWheelDeltaMultiplier * [event deltaY]); | 142 // Multiply by 1000 to vaguely approximate WHEEL_DELTA on Windows (120). |
143 const CGFloat kWheelDeltaMultiplier = 1000; | |
144 return gfx::Vector2d(kWheelDeltaMultiplier * [event deltaX], | |
145 kWheelDeltaMultiplier * [event deltaY]); | |
146 } | |
141 } | 147 } |
142 | 148 |
143 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { | 149 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { |
144 return [event copy]; | 150 return [event copy]; |
145 } | 151 } |
146 | 152 |
147 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { | 153 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { |
148 [event release]; | 154 [event release]; |
149 } | 155 } |
150 | 156 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 uint16 return_value; | 259 uint16 return_value; |
254 [text getCharacters:&return_value]; | 260 [text getCharacters:&return_value]; |
255 return return_value; | 261 return return_value; |
256 } | 262 } |
257 | 263 |
258 bool IsCharFromNative(const base::NativeEvent& native_event) { | 264 bool IsCharFromNative(const base::NativeEvent& native_event) { |
259 return false; | 265 return false; |
260 } | 266 } |
261 | 267 |
262 } // namespace ui | 268 } // namespace ui |
OLD | NEW |