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" |
18 | |
miu
2016/05/16 20:05:35
Please remove blank line here.
majidvp
2016/05/21 01:38:00
Done.
| |
17 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 19 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
18 #include "ui/gfx/geometry/point.h" | 20 #include "ui/gfx/geometry/point.h" |
19 #include "ui/gfx/geometry/vector2d.h" | 21 #include "ui/gfx/geometry/vector2d.h" |
20 | 22 |
21 namespace ui { | 23 namespace ui { |
22 | 24 |
23 EventType EventTypeFromNative(const base::NativeEvent& native_event) { | 25 EventType EventTypeFromNative(const base::NativeEvent& native_event) { |
24 NSEventType type = [native_event type]; | 26 NSEventType type = [native_event type]; |
25 switch (type) { | 27 switch (type) { |
26 case NSKeyDown: | 28 case NSKeyDown: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 break; | 72 break; |
71 } | 73 } |
72 return ET_UNKNOWN; | 74 return ET_UNKNOWN; |
73 } | 75 } |
74 | 76 |
75 int EventFlagsFromNative(const base::NativeEvent& event) { | 77 int EventFlagsFromNative(const base::NativeEvent& event) { |
76 NSUInteger modifiers = [event modifierFlags]; | 78 NSUInteger modifiers = [event modifierFlags]; |
77 return EventFlagsFromNSEventWithModifiers(event, modifiers); | 79 return EventFlagsFromNSEventWithModifiers(event, modifiers); |
78 } | 80 } |
79 | 81 |
80 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { | 82 base::TimeTicks EventTimeFromNative(const base::NativeEvent& native_event) { |
81 NSTimeInterval since_system_startup = [native_event timestamp]; | 83 NSTimeInterval since_system_startup = [native_event timestamp]; |
82 // Truncate to extract seconds before doing floating point arithmetic. | 84 // Truncate to extract seconds before doing floating point arithmetic. |
83 int64_t seconds = since_system_startup; | 85 int64_t seconds = since_system_startup; |
84 since_system_startup -= seconds; | 86 since_system_startup -= seconds; |
85 int64_t microseconds = since_system_startup * 1000000; | 87 int64_t microseconds = since_system_startup * 1000000; |
86 return base::TimeDelta::FromSeconds(seconds) + | 88 return ui::EventTimeStampFromSeconds(seconds) + |
miu
2016/05/16 20:05:35
This feels brittle. How will you ensure this remai
majidvp
2016/05/21 01:38:00
Good point. I added a DCHECK to ensure it is withi
| |
87 base::TimeDelta::FromMicroseconds(microseconds); | 89 base::TimeDelta::FromMicroseconds(microseconds); |
88 } | 90 } |
89 | 91 |
90 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 92 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
91 NSWindow* window = [native_event window]; | 93 NSWindow* window = [native_event window]; |
92 if (!window) { | 94 if (!window) { |
93 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 95 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
94 return gfx::Point(); | 96 return gfx::Point(); |
95 } | 97 } |
96 NSPoint location = [native_event locationInWindow]; | 98 NSPoint location = [native_event locationInWindow]; |
97 NSRect content_rect = [window contentRectForFrameRect:[window frame]]; | 99 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; | 260 uint16_t return_value; |
259 [text getCharacters:&return_value]; | 261 [text getCharacters:&return_value]; |
260 return return_value; | 262 return return_value; |
261 } | 263 } |
262 | 264 |
263 bool IsCharFromNative(const base::NativeEvent& native_event) { | 265 bool IsCharFromNative(const base::NativeEvent& native_event) { |
264 return false; | 266 return false; |
265 } | 267 } |
266 | 268 |
267 } // namespace ui | 269 } // namespace ui |
OLD | NEW |