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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return base::TimeDelta::FromSeconds(seconds) + | 85 return base::TimeDelta::FromSeconds(seconds) + |
86 base::TimeDelta::FromMicroseconds(microseconds); | 86 base::TimeDelta::FromMicroseconds(microseconds); |
87 } | 87 } |
88 | 88 |
89 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | 89 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { |
90 if (![native_event window]) { | 90 if (![native_event window]) { |
91 NOTIMPLEMENTED(); // Point will be in screen coordinates. | 91 NOTIMPLEMENTED(); // Point will be in screen coordinates. |
92 return gfx::Point(); | 92 return gfx::Point(); |
93 } | 93 } |
94 NSPoint location = [native_event locationInWindow]; | 94 NSPoint location = [native_event locationInWindow]; |
95 return gfx::Point(location.x, | 95 NSRect window_frame = [[native_event window] frame]; |
96 NSHeight([[native_event window] frame]) - location.y); | 96 CGFloat content_height = |
| 97 NSHeight([[native_event window] contentRectForFrameRect:window_frame]); |
| 98 return gfx::Point(location.x, content_height - location.y); |
97 } | 99 } |
98 | 100 |
99 gfx::Point EventSystemLocationFromNative( | 101 gfx::Point EventSystemLocationFromNative( |
100 const base::NativeEvent& native_event) { | 102 const base::NativeEvent& native_event) { |
101 NOTIMPLEMENTED(); | 103 NOTIMPLEMENTED(); |
102 return gfx::Point(); | 104 return gfx::Point(); |
103 } | 105 } |
104 | 106 |
105 int EventButtonFromNative(const base::NativeEvent& native_event) { | 107 int EventButtonFromNative(const base::NativeEvent& native_event) { |
106 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 220 |
219 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | 221 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { |
220 return KeyboardCodeFromNSEvent(native_event); | 222 return KeyboardCodeFromNSEvent(native_event); |
221 } | 223 } |
222 | 224 |
223 const char* CodeFromNative(const base::NativeEvent& native_event) { | 225 const char* CodeFromNative(const base::NativeEvent& native_event) { |
224 return CodeFromNSEvent(native_event); | 226 return CodeFromNSEvent(native_event); |
225 } | 227 } |
226 | 228 |
227 } // namespace ui | 229 } // namespace ui |
OLD | NEW |