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

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

Issue 231883003: [stash] 20140404-crbug-312961-mac-views-bridge-C-wholegrid Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « ui/events/cocoa/cocoa_event_utils.mm ('k') | ui/events/event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/events/event_utils.h"
6
7 #include <Cocoa/Cocoa.h>
8
9 #include "base/logging.h"
10 #include "base/time/time.h"
11 #include "build/build_config.h"
12 #include "ui/events/cocoa/cocoa_event_utils.h"
13 #include "ui/events/event_utils.h"
14 #import "ui/events/keycodes/keyboard_code_conversion_mac.h"
15 #include "ui/gfx/point.h"
16 #include "ui/gfx/vector2d.h"
17
18 enum { NSEventTypeSmartMagnify = 32, NSEventTypeQuickLook = 33 };
19
20 namespace ui {
21
22 void UpdateDeviceList() { NOTIMPLEMENTED(); }
23
24 EventType EventTypeFromNative(const base::NativeEvent& native_event) {
25 NSEventType type = [native_event type];
26 switch (type) {
27 case NSKeyDown:
28 return ET_KEY_PRESSED;
29 case NSKeyUp:
30 return ET_KEY_RELEASED;
31 case NSLeftMouseDown:
32 case NSRightMouseDown:
33 case NSOtherMouseDown:
34 return ET_MOUSE_PRESSED;
35 case NSLeftMouseUp:
36 case NSRightMouseUp:
37 case NSOtherMouseUp:
38 return ET_MOUSE_RELEASED;
39 case NSLeftMouseDragged:
40 case NSRightMouseDragged:
41 case NSOtherMouseDragged:
42 return ET_MOUSE_DRAGGED;
43 case NSMouseMoved:
44 case NSScrollWheel:
45 return ET_MOUSEWHEEL;
46 case NSMouseEntered:
47 return ET_MOUSE_ENTERED;
48 case NSMouseExited:
49 return ET_MOUSE_EXITED;
50 case NSEventTypeSwipe:
51 return ET_GESTURE_MULTIFINGER_SWIPE;
52 case NSFlagsChanged:
53 case NSAppKitDefined:
54 case NSSystemDefined:
55 case NSApplicationDefined:
56 case NSPeriodic:
57 case NSCursorUpdate:
58 case NSTabletPoint:
59 case NSTabletProximity:
60 case NSEventTypeGesture:
61 case NSEventTypeMagnify:
62 case NSEventTypeRotate:
63 case NSEventTypeBeginGesture:
64 case NSEventTypeEndGesture:
65 NOTIMPLEMENTED() << type;
66 break;
67 default:
68 break;
69 }
70 return ET_UNKNOWN;
71 }
72
73 int EventFlagsFromNative(const base::NativeEvent& event) {
74 NSUInteger modifiers = [event modifierFlags];
75 return EventFlagsFromNSEventWithModifiers(event, modifiers);
76 }
77
78 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) {
79 NSTimeInterval since_system_startup = [native_event timestamp];
80 int64_t seconds = since_system_startup;
81 since_system_startup -= seconds;
82 int64_t microseconds = since_system_startup * 1000000;
83 return base::TimeDelta::FromMicroseconds(seconds * 1000000 + microseconds);
84 }
85
86 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) {
87 if (![native_event window]) {
88 NOTIMPLEMENTED(); // Point will be in screen coordinates.
89 }
90 NSPoint location = [native_event locationInWindow];
91 return gfx::Point(location.x,
92 NSHeight([[native_event window] frame]) - location.y);
93 }
94
95 gfx::Point EventSystemLocationFromNative(
96 const base::NativeEvent& native_event) {
97 NOTIMPLEMENTED();
98 return gfx::Point();
99 }
100
101 int EventButtonFromNative(const base::NativeEvent& native_event) {
102 NOTIMPLEMENTED();
103 return 0;
104 }
105
106 int GetChangedMouseButtonFlagsFromNative(
107 const base::NativeEvent& native_event) {
108 NSEventType type = [native_event type];
109 switch (type) {
110 case NSLeftMouseDown:
111 case NSLeftMouseUp:
112 case NSLeftMouseDragged:
113 return EF_LEFT_MOUSE_BUTTON;
114 case NSRightMouseDown:
115 case NSRightMouseUp:
116 case NSRightMouseDragged:
117 return EF_RIGHT_MOUSE_BUTTON;
118 case NSOtherMouseDown:
119 case NSOtherMouseUp:
120 case NSOtherMouseDragged:
121 return EF_MIDDLE_MOUSE_BUTTON;
122 }
123 return 0;
124 }
125
126 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
127 NOTIMPLEMENTED();
128 return gfx::Vector2d();
129 }
130
131 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
132 return [event copy];
133 }
134
135 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) {
136 [event release];
137 }
138
139 void ClearTouchIdIfReleased(const base::NativeEvent& native_event) {
140 NOTIMPLEMENTED();
141 }
142
143 int GetTouchId(const base::NativeEvent& native_event) {
144 NOTIMPLEMENTED();
145 return 0;
146 }
147
148 float GetTouchRadiusX(const base::NativeEvent& native_event) {
149 NOTIMPLEMENTED();
150 return 0.f;
151 }
152
153 float GetTouchRadiusY(const base::NativeEvent& native_event) {
154 NOTIMPLEMENTED();
155 return 0.f;
156 }
157
158 float GetTouchAngle(const base::NativeEvent& native_event) {
159 NOTIMPLEMENTED();
160 return 0.f;
161 }
162
163 float GetTouchForce(const base::NativeEvent& native_event) {
164 NOTIMPLEMENTED();
165 return 0.f;
166 }
167
168 bool GetScrollOffsets(const base::NativeEvent& native_event,
169 float* x_offset,
170 float* y_offset,
171 float* x_offset_ordinal,
172 float* y_offset_ordinal,
173 int* finger_count) {
174 NOTIMPLEMENTED();
175 return false;
176 }
177
178 bool GetFlingData(const base::NativeEvent& native_event,
179 float* vx,
180 float* vy,
181 float* vx_ordinal,
182 float* vy_ordinal,
183 bool* is_cancel) {
184 NOTIMPLEMENTED();
185 return false;
186 }
187
188 bool GetGestureTimes(const base::NativeEvent& native_event,
189 double* start_time,
190 double* end_time) {
191 NOTIMPLEMENTED();
192 return false;
193 }
194
195 void SetNaturalScroll(bool enabled) { NOTIMPLEMENTED(); }
196
197 bool IsNaturalScrollEnabled() {
198 NOTIMPLEMENTED();
199 return false;
200 }
201
202 bool IsTouchpadEvent(const base::NativeEvent& native_event) {
203 NOTIMPLEMENTED();
204 return false;
205 }
206
207 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
208 return KeyboardCodeFromNSEvent(native_event);
209 }
210
211 const char* CodeFromNative(const base::NativeEvent& native_event) {
212 return CodeFromNSEvent(native_event);
213 }
214
215 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/cocoa/cocoa_event_utils.mm ('k') | ui/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698