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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 break; | 70 break; |
71 } | 71 } |
72 return ET_UNKNOWN; | 72 return ET_UNKNOWN; |
73 } | 73 } |
74 | 74 |
75 int EventFlagsFromNative(const base::NativeEvent& event) { | 75 int EventFlagsFromNative(const base::NativeEvent& event) { |
76 NSUInteger modifiers = [event modifierFlags]; | 76 NSUInteger modifiers = [event modifierFlags]; |
77 return EventFlagsFromNSEventWithModifiers(event, modifiers); | 77 return EventFlagsFromNSEventWithModifiers(event, modifiers); |
78 } | 78 } |
79 | 79 |
80 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { | 80 base::TimeTicks EventTimeFromNative(const base::NativeEvent& native_event) { |
81 NSTimeInterval since_system_startup = [native_event timestamp]; | 81 NSTimeInterval since_system_startup = [native_event timestamp]; |
82 // Truncate to extract seconds before doing floating point arithmetic. | 82 // Truncate to extract seconds before doing floating point arithmetic. |
83 int64_t seconds = since_system_startup; | 83 int64_t seconds = since_system_startup; |
84 since_system_startup -= seconds; | 84 since_system_startup -= seconds; |
85 int64_t microseconds = since_system_startup * 1000000; | 85 int64_t microseconds = since_system_startup * 1000000; |
86 return base::TimeDelta::FromSeconds(seconds) + | 86 return base::TimeTicks() + base::TimeDelta::FromSeconds(seconds) + |
87 base::TimeDelta::FromMicroseconds(microseconds); | 87 base::TimeDelta::FromMicroseconds(microseconds); |
88 } | 88 } |
89 | 89 |
90 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 90 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
91 NSWindow* window = [native_event window]; | 91 NSWindow* window = [native_event window]; |
92 if (!window) { | 92 if (!window) { |
93 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 93 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
94 return gfx::Point(); | 94 return gfx::Point(); |
95 } | 95 } |
96 NSPoint location = [native_event locationInWindow]; | 96 NSPoint location = [native_event locationInWindow]; |
97 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; | 97 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; | 258 uint16_t return_value; |
259 [text getCharacters:&return_value]; | 259 [text getCharacters:&return_value]; |
260 return return_value; | 260 return return_value; |
261 } | 261 } |
262 | 262 |
263 bool IsCharFromNative(const base::NativeEvent& native_event) { | 263 bool IsCharFromNative(const base::NativeEvent& native_event) { |
264 return false; | 264 return false; |
265 } | 265 } |
266 | 266 |
267 } // namespace ui | 267 } // namespace ui |
OLD | NEW |