| 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" | 9 #include "base/memory/ptr_util.h" |
| 10 | 10 |
| 11 #if defined(USE_X11) | 11 #if defined(USE_X11) |
| 12 #include <X11/extensions/XInput2.h> | 12 #include <X11/extensions/XInput2.h> |
| 13 #include <X11/keysym.h> | 13 #include <X11/keysym.h> |
| 14 #include <X11/Xlib.h> | 14 #include <X11/Xlib.h> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #include <cmath> | 17 #include <cmath> |
| 18 #include <cstring> | 18 #include <cstring> |
| 19 | 19 |
| 20 #include "base/memory/ptr_util.h" |
| 20 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
| 21 #include "base/metrics/histogram_macros.h" | 22 #include "base/metrics/histogram_macros.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "ui/events/base_event_utils.h" | 25 #include "ui/events/base_event_utils.h" |
| 25 #include "ui/events/event_utils.h" | 26 #include "ui/events/event_utils.h" |
| 26 #include "ui/events/keycodes/dom/dom_code.h" | 27 #include "ui/events/keycodes/dom/dom_code.h" |
| 27 #include "ui/events/keycodes/dom/dom_key.h" | 28 #include "ui/events/keycodes/dom/dom_key.h" |
| 28 #include "ui/events/keycodes/dom/keycode_converter.h" | 29 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 29 #include "ui/events/keycodes/keyboard_code_conversion.h" | 30 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 key_code_(key_code), | 1197 key_code_(key_code), |
| 1197 code_(DomCode::NONE), | 1198 code_(DomCode::NONE), |
| 1198 is_char_(true), | 1199 is_char_(true), |
| 1199 key_(DomKey::FromCharacter(character)) {} | 1200 key_(DomKey::FromCharacter(character)) {} |
| 1200 | 1201 |
| 1201 KeyEvent::KeyEvent(const KeyEvent& rhs) | 1202 KeyEvent::KeyEvent(const KeyEvent& rhs) |
| 1202 : Event(rhs), | 1203 : Event(rhs), |
| 1203 key_code_(rhs.key_code_), | 1204 key_code_(rhs.key_code_), |
| 1204 code_(rhs.code_), | 1205 code_(rhs.code_), |
| 1205 is_char_(rhs.is_char_), | 1206 is_char_(rhs.is_char_), |
| 1206 key_(rhs.key_) { | 1207 key_(rhs.key_), |
| 1207 } | 1208 properties_(rhs.properties_ |
| 1209 ? base::MakeUnique<Properties>(*rhs.properties_) |
| 1210 : nullptr) {} |
| 1208 | 1211 |
| 1209 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { | 1212 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { |
| 1210 if (this != &rhs) { | 1213 if (this != &rhs) { |
| 1211 Event::operator=(rhs); | 1214 Event::operator=(rhs); |
| 1212 key_code_ = rhs.key_code_; | 1215 key_code_ = rhs.key_code_; |
| 1213 code_ = rhs.code_; | 1216 code_ = rhs.code_; |
| 1214 key_ = rhs.key_; | 1217 key_ = rhs.key_; |
| 1215 is_char_ = rhs.is_char_; | 1218 is_char_ = rhs.is_char_; |
| 1219 if (rhs.properties_) |
| 1220 properties_ = base::MakeUnique<Properties>(*rhs.properties_); |
| 1221 else |
| 1222 properties_.reset(); |
| 1216 } | 1223 } |
| 1217 latency()->set_source_event_type(ui::SourceEventType::OTHER); | 1224 latency()->set_source_event_type(ui::SourceEventType::OTHER); |
| 1218 return *this; | 1225 return *this; |
| 1219 } | 1226 } |
| 1220 | 1227 |
| 1221 KeyEvent::~KeyEvent() {} | 1228 KeyEvent::~KeyEvent() {} |
| 1222 | 1229 |
| 1223 void KeyEvent::ApplyLayout() const { | 1230 void KeyEvent::ApplyLayout() const { |
| 1224 ui::DomCode code = code_; | 1231 ui::DomCode code = code_; |
| 1225 if (code == DomCode::NONE) { | 1232 if (code == DomCode::NONE) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 break; | 1348 break; |
| 1342 default: | 1349 default: |
| 1343 return; | 1350 return; |
| 1344 } | 1351 } |
| 1345 if (type() == ET_KEY_PRESSED) | 1352 if (type() == ET_KEY_PRESSED) |
| 1346 set_flags(flags() | mask); | 1353 set_flags(flags() | mask); |
| 1347 else | 1354 else |
| 1348 set_flags(flags() & ~mask); | 1355 set_flags(flags() & ~mask); |
| 1349 } | 1356 } |
| 1350 | 1357 |
| 1358 void KeyEvent::SetProperties(const Properties& properties) { |
| 1359 properties_ = base::MakeUnique<Properties>(properties); |
| 1360 } |
| 1361 |
| 1351 KeyboardCode KeyEvent::GetLocatedWindowsKeyboardCode() const { | 1362 KeyboardCode KeyEvent::GetLocatedWindowsKeyboardCode() const { |
| 1352 return NonLocatedToLocatedKeyboardCode(key_code_, code_); | 1363 return NonLocatedToLocatedKeyboardCode(key_code_, code_); |
| 1353 } | 1364 } |
| 1354 | 1365 |
| 1355 uint16_t KeyEvent::GetConflatedWindowsKeyCode() const { | 1366 uint16_t KeyEvent::GetConflatedWindowsKeyCode() const { |
| 1356 if (is_char_) | 1367 if (is_char_) |
| 1357 return key_.ToCharacter(); | 1368 return key_.ToCharacter(); |
| 1358 return key_code_; | 1369 return key_code_; |
| 1359 } | 1370 } |
| 1360 | 1371 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 flags | EF_FROM_TOUCH), | 1447 flags | EF_FROM_TOUCH), |
| 1437 details_(details), | 1448 details_(details), |
| 1438 unique_touch_event_id_(unique_touch_event_id) { | 1449 unique_touch_event_id_(unique_touch_event_id) { |
| 1439 latency()->set_source_event_type(ui::SourceEventType::TOUCH); | 1450 latency()->set_source_event_type(ui::SourceEventType::TOUCH); |
| 1440 } | 1451 } |
| 1441 | 1452 |
| 1442 GestureEvent::~GestureEvent() { | 1453 GestureEvent::~GestureEvent() { |
| 1443 } | 1454 } |
| 1444 | 1455 |
| 1445 } // namespace ui | 1456 } // namespace ui |
| OLD | NEW |