| 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 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 #endif | 10 #endif |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 return false; | 511 return false; |
| 512 } | 512 } |
| 513 | 513 |
| 514 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) | 514 KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char) |
| 515 : Event(native_event, | 515 : Event(native_event, |
| 516 EventTypeFromNative(native_event), | 516 EventTypeFromNative(native_event), |
| 517 EventFlagsFromNative(native_event)), | 517 EventFlagsFromNative(native_event)), |
| 518 key_code_(KeyboardCodeFromNative(native_event)), | 518 key_code_(KeyboardCodeFromNative(native_event)), |
| 519 code_(CodeFromNative(native_event)), | 519 code_(CodeFromNative(native_event)), |
| 520 is_char_(is_char), | 520 is_char_(is_char), |
| 521 platform_keycode_(PlatformCodeFromNative(native_event)), |
| 521 character_(0) { | 522 character_(0) { |
| 522 if (IsRepeated(*this)) | 523 if (IsRepeated(*this)) |
| 523 set_flags(flags() | ui::EF_IS_REPEAT); | 524 set_flags(flags() | ui::EF_IS_REPEAT); |
| 524 | 525 |
| 525 #if defined(USE_X11) | 526 #if defined(USE_X11) |
| 526 NormalizeFlags(); | 527 NormalizeFlags(); |
| 527 #endif | 528 #endif |
| 528 } | 529 } |
| 529 | 530 |
| 530 KeyEvent::KeyEvent(EventType type, | 531 KeyEvent::KeyEvent(EventType type, |
| 531 KeyboardCode key_code, | 532 KeyboardCode key_code, |
| 532 int flags, | 533 int flags, |
| 533 bool is_char) | 534 bool is_char) |
| 534 : Event(type, EventTimeForNow(), flags), | 535 : Event(type, EventTimeForNow(), flags), |
| 535 key_code_(key_code), | 536 key_code_(key_code), |
| 536 is_char_(is_char), | 537 is_char_(is_char), |
| 538 platform_keycode_(0), |
| 537 character_(GetCharacterFromKeyCode(key_code, flags)) { | 539 character_(GetCharacterFromKeyCode(key_code, flags)) { |
| 538 } | 540 } |
| 539 | 541 |
| 540 KeyEvent::KeyEvent(EventType type, | 542 KeyEvent::KeyEvent(EventType type, |
| 541 KeyboardCode key_code, | 543 KeyboardCode key_code, |
| 542 const std::string& code, | 544 const std::string& code, |
| 543 int flags, | 545 int flags, |
| 544 bool is_char) | 546 bool is_char) |
| 545 : Event(type, EventTimeForNow(), flags), | 547 : Event(type, EventTimeForNow(), flags), |
| 546 key_code_(key_code), | 548 key_code_(key_code), |
| 547 code_(code), | 549 code_(code), |
| 548 is_char_(is_char), | 550 is_char_(is_char), |
| 551 platform_keycode_(0), |
| 549 character_(GetCharacterFromKeyCode(key_code, flags)) { | 552 character_(GetCharacterFromKeyCode(key_code, flags)) { |
| 550 } | 553 } |
| 551 | 554 |
| 552 uint16 KeyEvent::GetCharacter() const { | 555 uint16 KeyEvent::GetCharacter() const { |
| 553 if (character_) | 556 if (character_) |
| 554 return character_; | 557 return character_; |
| 555 | 558 |
| 556 #if defined(OS_WIN) | 559 #if defined(OS_WIN) |
| 557 return (native_event().message == WM_CHAR) ? key_code_ : | 560 return (native_event().message == WM_CHAR) ? key_code_ : |
| 558 GetCharacterFromKeyCode(key_code_, flags()); | 561 GetCharacterFromKeyCode(key_code_, flags()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 int GestureEvent::GetLowestTouchId() const { | 726 int GestureEvent::GetLowestTouchId() const { |
| 724 if (touch_ids_bitfield_ == 0) | 727 if (touch_ids_bitfield_ == 0) |
| 725 return -1; | 728 return -1; |
| 726 int i = -1; | 729 int i = -1; |
| 727 // Find the index of the least significant 1 bit | 730 // Find the index of the least significant 1 bit |
| 728 while (!(1 << ++i & touch_ids_bitfield_)); | 731 while (!(1 << ++i & touch_ids_bitfield_)); |
| 729 return i; | 732 return i; |
| 730 } | 733 } |
| 731 | 734 |
| 732 } // namespace ui | 735 } // namespace ui |
| OLD | NEW |