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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #import "base/mac/mac_util.h" | 11 #import "base/mac/mac_util.h" |
12 #import "base/mac/sdk_forward_declarations.h" | 12 #import "base/mac/sdk_forward_declarations.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ui/events/base_event_utils.h" |
15 #include "ui/events/cocoa/cocoa_event_utils.h" | 16 #include "ui/events/cocoa/cocoa_event_utils.h" |
16 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
17 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 18 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
18 #include "ui/gfx/geometry/point.h" | 19 #include "ui/gfx/geometry/point.h" |
19 #include "ui/gfx/geometry/vector2d.h" | 20 #include "ui/gfx/geometry/vector2d.h" |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 | 23 |
23 EventType EventTypeFromNative(const base::NativeEvent& native_event) { | 24 EventType EventTypeFromNative(const base::NativeEvent& native_event) { |
24 NSEventType type = [native_event type]; | 25 NSEventType type = [native_event type]; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 break; | 71 break; |
71 } | 72 } |
72 return ET_UNKNOWN; | 73 return ET_UNKNOWN; |
73 } | 74 } |
74 | 75 |
75 int EventFlagsFromNative(const base::NativeEvent& event) { | 76 int EventFlagsFromNative(const base::NativeEvent& event) { |
76 NSUInteger modifiers = [event modifierFlags]; | 77 NSUInteger modifiers = [event modifierFlags]; |
77 return EventFlagsFromNSEventWithModifiers(event, modifiers); | 78 return EventFlagsFromNSEventWithModifiers(event, modifiers); |
78 } | 79 } |
79 | 80 |
80 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { | 81 base::TimeTicks EventTimeFromNative(const base::NativeEvent& native_event) { |
81 NSTimeInterval since_system_startup = [native_event timestamp]; | 82 NSTimeInterval since_system_startup = [native_event timestamp]; |
82 // Truncate to extract seconds before doing floating point arithmetic. | 83 // Truncate to extract seconds before doing floating point arithmetic. |
83 int64_t seconds = since_system_startup; | 84 int64_t seconds = since_system_startup; |
84 since_system_startup -= seconds; | 85 since_system_startup -= seconds; |
85 int64_t microseconds = since_system_startup * 1000000; | 86 int64_t microseconds = since_system_startup * 1000000; |
86 return base::TimeDelta::FromSeconds(seconds) + | 87 return ui::EventTimeStampFromSeconds(seconds) + |
87 base::TimeDelta::FromMicroseconds(microseconds); | 88 base::TimeDelta::FromMicroseconds(microseconds); |
88 } | 89 } |
89 | 90 |
90 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 91 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
91 NSWindow* window = [native_event window]; | 92 NSWindow* window = [native_event window]; |
92 if (!window) { | 93 if (!window) { |
93 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 94 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
94 return gfx::Point(); | 95 return gfx::Point(); |
95 } | 96 } |
96 NSPoint location = [native_event locationInWindow]; | 97 NSPoint location = [native_event locationInWindow]; |
97 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; | 98 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 uint16_t return_value; | 259 uint16_t return_value; |
259 [text getCharacters:&return_value]; | 260 [text getCharacters:&return_value]; |
260 return return_value; | 261 return return_value; |
261 } | 262 } |
262 | 263 |
263 bool IsCharFromNative(const base::NativeEvent& native_event) { | 264 bool IsCharFromNative(const base::NativeEvent& native_event) { |
264 return false; | 265 return false; |
265 } | 266 } |
266 | 267 |
267 } // namespace ui | 268 } // namespace ui |
OLD | NEW |