| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "ui/events/event.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
| 10 |
| 9 #if defined(USE_X11) | 11 #if defined(USE_X11) |
| 10 #include <X11/extensions/XInput2.h> | 12 #include <X11/extensions/XInput2.h> |
| 11 #include <X11/keysym.h> | 13 #include <X11/keysym.h> |
| 12 #include <X11/Xlib.h> | 14 #include <X11/Xlib.h> |
| 13 #endif | 15 #endif |
| 14 | 16 |
| 15 #include <cmath> | 17 #include <cmath> |
| 16 #include <cstring> | 18 #include <cstring> |
| 17 | 19 |
| 18 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 158 } |
| 157 | 159 |
| 158 } // namespace | 160 } // namespace |
| 159 | 161 |
| 160 namespace ui { | 162 namespace ui { |
| 161 | 163 |
| 162 //////////////////////////////////////////////////////////////////////////////// | 164 //////////////////////////////////////////////////////////////////////////////// |
| 163 // Event | 165 // Event |
| 164 | 166 |
| 165 // static | 167 // static |
| 166 scoped_ptr<Event> Event::Clone(const Event& event) { | 168 std::unique_ptr<Event> Event::Clone(const Event& event) { |
| 167 if (event.IsKeyEvent()) { | 169 if (event.IsKeyEvent()) { |
| 168 return make_scoped_ptr(new KeyEvent(static_cast<const KeyEvent&>(event))); | 170 return base::WrapUnique(new KeyEvent(static_cast<const KeyEvent&>(event))); |
| 169 } | 171 } |
| 170 | 172 |
| 171 if (event.IsMouseEvent()) { | 173 if (event.IsMouseEvent()) { |
| 172 if (event.IsMouseWheelEvent()) { | 174 if (event.IsMouseWheelEvent()) { |
| 173 return make_scoped_ptr( | 175 return base::WrapUnique( |
| 174 new MouseWheelEvent(static_cast<const MouseWheelEvent&>(event))); | 176 new MouseWheelEvent(static_cast<const MouseWheelEvent&>(event))); |
| 175 } | 177 } |
| 176 | 178 |
| 177 return make_scoped_ptr( | 179 return base::WrapUnique( |
| 178 new MouseEvent(static_cast<const MouseEvent&>(event))); | 180 new MouseEvent(static_cast<const MouseEvent&>(event))); |
| 179 } | 181 } |
| 180 | 182 |
| 181 if (event.IsTouchEvent()) { | 183 if (event.IsTouchEvent()) { |
| 182 return make_scoped_ptr( | 184 return base::WrapUnique( |
| 183 new TouchEvent(static_cast<const TouchEvent&>(event))); | 185 new TouchEvent(static_cast<const TouchEvent&>(event))); |
| 184 } | 186 } |
| 185 | 187 |
| 186 if (event.IsGestureEvent()) { | 188 if (event.IsGestureEvent()) { |
| 187 return make_scoped_ptr( | 189 return base::WrapUnique( |
| 188 new GestureEvent(static_cast<const GestureEvent&>(event))); | 190 new GestureEvent(static_cast<const GestureEvent&>(event))); |
| 189 } | 191 } |
| 190 | 192 |
| 191 if (event.IsPointerEvent()) { | 193 if (event.IsPointerEvent()) { |
| 192 return make_scoped_ptr( | 194 return base::WrapUnique( |
| 193 new PointerEvent(static_cast<const PointerEvent&>(event))); | 195 new PointerEvent(static_cast<const PointerEvent&>(event))); |
| 194 } | 196 } |
| 195 | 197 |
| 196 if (event.IsScrollEvent()) { | 198 if (event.IsScrollEvent()) { |
| 197 return make_scoped_ptr( | 199 return base::WrapUnique( |
| 198 new ScrollEvent(static_cast<const ScrollEvent&>(event))); | 200 new ScrollEvent(static_cast<const ScrollEvent&>(event))); |
| 199 } | 201 } |
| 200 | 202 |
| 201 return make_scoped_ptr(new Event(event)); | 203 return base::WrapUnique(new Event(event)); |
| 202 } | 204 } |
| 203 | 205 |
| 204 Event::~Event() { | 206 Event::~Event() { |
| 205 if (delete_native_event_) | 207 if (delete_native_event_) |
| 206 ReleaseCopiedNativeEvent(native_event_); | 208 ReleaseCopiedNativeEvent(native_event_); |
| 207 } | 209 } |
| 208 | 210 |
| 209 bool Event::IsMousePointerEvent() const { | 211 bool Event::IsMousePointerEvent() const { |
| 210 return IsPointerEvent() && | 212 return IsPointerEvent() && |
| 211 AsPointerEvent()->pointer_details().pointer_type == | 213 AsPointerEvent()->pointer_details().pointer_type == |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 is_char_ = rhs.is_char_; | 981 is_char_ = rhs.is_char_; |
| 980 | 982 |
| 981 if (rhs.extended_key_event_data_) | 983 if (rhs.extended_key_event_data_) |
| 982 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); | 984 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); |
| 983 } | 985 } |
| 984 return *this; | 986 return *this; |
| 985 } | 987 } |
| 986 | 988 |
| 987 KeyEvent::~KeyEvent() {} | 989 KeyEvent::~KeyEvent() {} |
| 988 | 990 |
| 989 void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { | 991 void KeyEvent::SetExtendedKeyEventData( |
| 992 std::unique_ptr<ExtendedKeyEventData> data) { |
| 990 extended_key_event_data_ = std::move(data); | 993 extended_key_event_data_ = std::move(data); |
| 991 } | 994 } |
| 992 | 995 |
| 993 void KeyEvent::ApplyLayout() const { | 996 void KeyEvent::ApplyLayout() const { |
| 994 ui::DomCode code = code_; | 997 ui::DomCode code = code_; |
| 995 if (code == DomCode::NONE) { | 998 if (code == DomCode::NONE) { |
| 996 // Catch old code that tries to do layout without a physical key, and try | 999 // Catch old code that tries to do layout without a physical key, and try |
| 997 // to recover using the KeyboardCode. Once key events are fully defined | 1000 // to recover using the KeyboardCode. Once key events are fully defined |
| 998 // on construction (see TODO in event.h) this will go away. | 1001 // on construction (see TODO in event.h) this will go away. |
| 999 VLOG(2) << "DomCode::NONE keycode=" << key_code_; | 1002 VLOG(2) << "DomCode::NONE keycode=" << key_code_; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 gfx::PointF(x, y), | 1204 gfx::PointF(x, y), |
| 1202 time_stamp, | 1205 time_stamp, |
| 1203 flags | EF_FROM_TOUCH), | 1206 flags | EF_FROM_TOUCH), |
| 1204 details_(details) { | 1207 details_(details) { |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1207 GestureEvent::~GestureEvent() { | 1210 GestureEvent::~GestureEvent() { |
| 1208 } | 1211 } |
| 1209 | 1212 |
| 1210 } // namespace ui | 1213 } // namespace ui |
| OLD | NEW |