OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura/event.h" | 5 #include "ui/aura/event.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #endif | 9 #endif |
10 | 10 |
| 11 #include <cstring> |
| 12 |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 #include "ui/base/keycodes/keyboard_code_conversion.h" | 14 #include "ui/base/keycodes/keyboard_code_conversion.h" |
13 #include "ui/gfx/point3.h" | 15 #include "ui/gfx/point3.h" |
14 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
15 | 17 |
16 #if defined(USE_X11) | 18 #if defined(USE_X11) |
17 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 19 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
18 #endif | 20 #endif |
19 | 21 |
20 #if !defined(OS_WIN) | 22 #if !defined(OS_WIN) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 73 } |
72 | 74 |
73 Event::Event(const Event& copy) | 75 Event::Event(const Event& copy) |
74 : native_event_(copy.native_event_), | 76 : native_event_(copy.native_event_), |
75 type_(copy.type_), | 77 type_(copy.type_), |
76 time_stamp_(copy.time_stamp_), | 78 time_stamp_(copy.time_stamp_), |
77 flags_(copy.flags_) { | 79 flags_(copy.flags_) { |
78 } | 80 } |
79 | 81 |
80 void Event::Init() { | 82 void Event::Init() { |
81 memset(&native_event_, 0, sizeof(native_event_)); | 83 std::memset(&native_event_, 0, sizeof(native_event_)); |
| 84 } |
| 85 |
| 86 bool Event::HasNativeEvent() const { |
| 87 base::NativeEvent null_event; |
| 88 std::memset(&null_event, 0, sizeof(null_event)); |
| 89 return !!std::memcmp(&native_event_, &null_event, sizeof(null_event)); |
82 } | 90 } |
83 | 91 |
84 void Event::InitWithNativeEvent(const base::NativeEvent& native_event) { | 92 void Event::InitWithNativeEvent(const base::NativeEvent& native_event) { |
85 native_event_ = native_event; | 93 native_event_ = native_event; |
86 } | 94 } |
87 | 95 |
88 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) | 96 LocatedEvent::LocatedEvent(const base::NativeEvent& native_event) |
89 : Event(native_event, | 97 : Event(native_event, |
90 ui::EventTypeFromNative(native_event), | 98 ui::EventTypeFromNative(native_event), |
91 ui::EventFlagsFromNative(native_event)), | 99 ui::EventFlagsFromNative(native_event)), |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 uint16 ch = ui::GetCharacterFromXEvent(native_event()); | 253 uint16 ch = ui::GetCharacterFromXEvent(native_event()); |
246 return ch ? ch : | 254 return ch ? ch : |
247 ui::GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN); | 255 ui::GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN); |
248 #else | 256 #else |
249 NOTIMPLEMENTED(); | 257 NOTIMPLEMENTED(); |
250 return 0; | 258 return 0; |
251 #endif | 259 #endif |
252 } | 260 } |
253 | 261 |
254 } // namespace aura | 262 } // namespace aura |
OLD | NEW |