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

Side by Side Diff: ui/events/cocoa/events_mac.mm

Issue 456913002: MacViews: Support continuous scrolling and horizontal scrolling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for rsesek Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)] &&
Andre 2014/09/02 17:31:42 Yeah, I think it is safe to assume hasPreciseScrol
134 // values when scrolling up or to the left. Scrolling quickly results in a 136 [event hasPreciseScrollingDeltas]) {
135 // higher delta per click, up to about 15.0. (Quartz documentation suggests 137 // Handle continuous scrolling devices such as a Magic Mouse or a trackpad.
136 // +/-10). 138 // -scrollingDelta{X|Y} have float return types but they return values that
137 // Multiply by 1000 to vaguely approximate WHEEL_DELTA on Windows (120). 139 // are already rounded to integers.
138 const CGFloat kWheelDeltaMultiplier = 1000; 140 // The values are the same as the values returned from calling
139 return gfx::Vector2d(kWheelDeltaMultiplier * [event deltaX], 141 // CGEventGetIntegerValueField(kCGScrollWheelEventPointDeltaAxis{1|2}).
140 kWheelDeltaMultiplier * [event deltaY]); 142 return gfx::Vector2d([event scrollingDeltaX], [event scrollingDeltaY]);
143 } else {
144 // Empirically, a value of 0.1 is typical for one mousewheel click. Positive
145 // values when scrolling up or to the left. Scrolling quickly results in a
146 // higher delta per click, up to about 15.0. (Quartz documentation suggests
147 // +/-10).
148 // Multiply by 1000 to vaguely approximate WHEEL_DELTA on Windows (120).
149 const CGFloat kWheelDeltaMultiplier = 1000;
150 return gfx::Vector2d(kWheelDeltaMultiplier * [event deltaX],
151 kWheelDeltaMultiplier * [event deltaY]);
152 }
141 } 153 }
142 154
143 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { 155 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
144 return [event copy]; 156 return [event copy];
145 } 157 }
146 158
147 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { 159 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) {
148 [event release]; 160 [event release];
149 } 161 }
150 162
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 uint16 return_value; 265 uint16 return_value;
254 [text getCharacters:&return_value]; 266 [text getCharacters:&return_value];
255 return return_value; 267 return return_value;
256 } 268 }
257 269
258 bool IsCharFromNative(const base::NativeEvent& native_event) { 270 bool IsCharFromNative(const base::NativeEvent& native_event) {
259 return false; 271 return false;
260 } 272 }
261 273
262 } // namespace ui 274 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698