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/keysym.h> | 9 #include <X11/keysym.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 last_key_event_ = new KeyEvent(event); | 665 last_key_event_ = new KeyEvent(event); |
666 return false; | 666 return false; |
667 } | 667 } |
668 | 668 |
669 KeyEvent::KeyEvent(const base::NativeEvent& native_event) | 669 KeyEvent::KeyEvent(const base::NativeEvent& native_event) |
670 : Event(native_event, | 670 : Event(native_event, |
671 EventTypeFromNative(native_event), | 671 EventTypeFromNative(native_event), |
672 EventFlagsFromNative(native_event)), | 672 EventFlagsFromNative(native_event)), |
673 key_code_(KeyboardCodeFromNative(native_event)), | 673 key_code_(KeyboardCodeFromNative(native_event)), |
674 code_(CodeFromNative(native_event)), | 674 code_(CodeFromNative(native_event)), |
675 is_char_(IsCharFromNative(native_event)), | 675 is_char_(IsCharFromNative(native_event)) { |
676 platform_keycode_(PlatformKeycodeFromNative(native_event)) { | |
677 if (IsRepeated(*this)) | 676 if (IsRepeated(*this)) |
678 set_flags(flags() | ui::EF_IS_REPEAT); | 677 set_flags(flags() | ui::EF_IS_REPEAT); |
679 | 678 |
680 #if defined(USE_X11) | 679 #if defined(USE_X11) |
681 NormalizeFlags(); | 680 NormalizeFlags(); |
682 #endif | 681 #endif |
683 #if defined(OS_WIN) | 682 #if defined(OS_WIN) |
684 // Only Windows has native character events. | 683 // Only Windows has native character events. |
685 if (is_char_) | 684 if (is_char_) |
686 key_ = DomKey::FromCharacter(native_event.wParam); | 685 key_ = DomKey::FromCharacter(native_event.wParam); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 code_(DomCode::NONE), | 721 code_(DomCode::NONE), |
723 is_char_(true), | 722 is_char_(true), |
724 key_(DomKey::FromCharacter(character)) { | 723 key_(DomKey::FromCharacter(character)) { |
725 } | 724 } |
726 | 725 |
727 KeyEvent::KeyEvent(const KeyEvent& rhs) | 726 KeyEvent::KeyEvent(const KeyEvent& rhs) |
728 : Event(rhs), | 727 : Event(rhs), |
729 key_code_(rhs.key_code_), | 728 key_code_(rhs.key_code_), |
730 code_(rhs.code_), | 729 code_(rhs.code_), |
731 is_char_(rhs.is_char_), | 730 is_char_(rhs.is_char_), |
732 platform_keycode_(rhs.platform_keycode_), | |
733 key_(rhs.key_) { | 731 key_(rhs.key_) { |
734 if (rhs.extended_key_event_data_) | 732 if (rhs.extended_key_event_data_) |
735 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); | 733 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); |
736 } | 734 } |
737 | 735 |
738 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { | 736 KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { |
739 if (this != &rhs) { | 737 if (this != &rhs) { |
740 Event::operator=(rhs); | 738 Event::operator=(rhs); |
741 key_code_ = rhs.key_code_; | 739 key_code_ = rhs.key_code_; |
742 code_ = rhs.code_; | 740 code_ = rhs.code_; |
743 key_ = rhs.key_; | 741 key_ = rhs.key_; |
744 is_char_ = rhs.is_char_; | 742 is_char_ = rhs.is_char_; |
745 platform_keycode_ = rhs.platform_keycode_; | |
746 | 743 |
747 if (rhs.extended_key_event_data_) | 744 if (rhs.extended_key_event_data_) |
748 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); | 745 extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); |
749 } | 746 } |
750 return *this; | 747 return *this; |
751 } | 748 } |
752 | 749 |
753 KeyEvent::~KeyEvent() {} | 750 KeyEvent::~KeyEvent() {} |
754 | 751 |
755 void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { | 752 void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { |
(...skipping 22 matching lines...) Expand all Loading... |
778 // When a control key is held, prefer ASCII characters to non ASCII | 775 // When a control key is held, prefer ASCII characters to non ASCII |
779 // characters in order to use it for shortcut keys. GetCharacterFromKeyCode | 776 // characters in order to use it for shortcut keys. GetCharacterFromKeyCode |
780 // returns 'a' for VKEY_A even if the key is actually bound to 'à' in X11. | 777 // returns 'a' for VKEY_A even if the key is actually bound to 'à' in X11. |
781 // GetCharacterFromXEvent returns 'à' in that case. | 778 // GetCharacterFromXEvent returns 'à' in that case. |
782 if (!IsControlDown() && native_event()) { | 779 if (!IsControlDown() && native_event()) { |
783 key_ = GetDomKeyFromXEvent(native_event()); | 780 key_ = GetDomKeyFromXEvent(native_event()); |
784 return; | 781 return; |
785 } | 782 } |
786 #elif defined(USE_OZONE) | 783 #elif defined(USE_OZONE) |
787 if (KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup( | 784 if (KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup( |
788 code, flags(), &key_, &dummy_key_code, &platform_keycode_)) { | 785 code, flags(), &key_, &dummy_key_code)) { |
789 return; | 786 return; |
790 } | 787 } |
791 #else | 788 #else |
792 if (native_event()) { | 789 if (native_event()) { |
793 DCHECK(EventTypeFromNative(native_event()) == ET_KEY_PRESSED || | 790 DCHECK(EventTypeFromNative(native_event()) == ET_KEY_PRESSED || |
794 EventTypeFromNative(native_event()) == ET_KEY_RELEASED); | 791 EventTypeFromNative(native_event()) == ET_KEY_RELEASED); |
795 } | 792 } |
796 #endif | 793 #endif |
797 if (!DomCodeToUsLayoutDomKey(code, flags(), &key_, &dummy_key_code)) | 794 if (!DomCodeToUsLayoutDomKey(code, flags(), &key_, &dummy_key_code)) |
798 key_ = DomKey::UNIDENTIFIED; | 795 key_ = DomKey::UNIDENTIFIED; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 gfx::PointF(x, y), | 951 gfx::PointF(x, y), |
955 time_stamp, | 952 time_stamp, |
956 flags | EF_FROM_TOUCH), | 953 flags | EF_FROM_TOUCH), |
957 details_(details) { | 954 details_(details) { |
958 } | 955 } |
959 | 956 |
960 GestureEvent::~GestureEvent() { | 957 GestureEvent::~GestureEvent() { |
961 } | 958 } |
962 | 959 |
963 } // namespace ui | 960 } // namespace ui |
OLD | NEW |