Chromium Code Reviews| 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 #ifndef UI_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
| 6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_EVENT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 527 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
| 528 // See also: ui/events/keycodes/dom4/keycode_converter_data.h | 528 // See also: ui/events/keycodes/dom4/keycode_converter_data.h |
| 529 KeyEvent(EventType type, KeyboardCode key_code, const std::string& code, | 529 KeyEvent(EventType type, KeyboardCode key_code, const std::string& code, |
| 530 int flags, bool is_char); | 530 int flags, bool is_char); |
| 531 | 531 |
| 532 // This allows an I18N virtual keyboard to fabricate a keyboard event that | 532 // This allows an I18N virtual keyboard to fabricate a keyboard event that |
| 533 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small | 533 // does not have a corresponding KeyboardCode (example: U+00E1 Latin small |
| 534 // letter A with acute, U+0410 Cyrillic capital letter A). | 534 // letter A with acute, U+0410 Cyrillic capital letter A). |
| 535 void set_character(uint16 character) { character_ = character; } | 535 void set_character(uint16 character) { character_ = character; } |
| 536 | 536 |
| 537 // This allows some platforms other than XKB to set its original key code. | |
| 538 // e.g. Key event from Ozone will not have native key event. So it can use | |
| 539 // this method to set the xksym value. | |
| 540 void set_platform_keycode(uint32 keycode) { platform_keycode_ = keycode; } | |
| 541 | |
| 537 // Gets the character generated by this key event. It only supports Unicode | 542 // Gets the character generated by this key event. It only supports Unicode |
| 538 // BMP characters. | 543 // BMP characters. |
| 539 uint16 GetCharacter() const; | 544 uint16 GetCharacter() const; |
| 540 | 545 |
| 546 // Gets the platform key code. For XKB, this is the xksym value. | |
| 547 uint32 platform_keycode() const { return platform_keycode_; } | |
| 541 KeyboardCode key_code() const { return key_code_; } | 548 KeyboardCode key_code() const { return key_code_; } |
| 542 bool is_char() const { return is_char_; } | 549 bool is_char() const { return is_char_; } |
| 543 | 550 |
| 544 // This is only intended to be used externally by classes that are modifying | 551 // This is only intended to be used externally by classes that are modifying |
| 545 // events in EventFilter::PreHandleKeyEvent(). set_character() should also be | 552 // events in EventFilter::PreHandleKeyEvent(). set_character() should also be |
| 546 // called. | 553 // called. |
| 547 void set_key_code(KeyboardCode key_code) { key_code_ = key_code; } | 554 void set_key_code(KeyboardCode key_code) { key_code_ = key_code; } |
| 548 | 555 |
| 549 // Returns true for [Alt]+<num-pad digit> Unicode alt key codes used by Win. | 556 // Returns true for [Alt]+<num-pad digit> Unicode alt key codes used by Win. |
| 550 // TODO(msw): Additional work may be needed for analogues on other platforms. | 557 // TODO(msw): Additional work may be needed for analogues on other platforms. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 561 // and there is no need to pass the key event to the input method again. | 568 // and there is no need to pass the key event to the input method again. |
| 562 bool IsTranslated() const; | 569 bool IsTranslated() const; |
| 563 // Marks this key event as translated or not translated. | 570 // Marks this key event as translated or not translated. |
| 564 void SetTranslated(bool translated); | 571 void SetTranslated(bool translated); |
| 565 | 572 |
| 566 protected: | 573 protected: |
| 567 // This allows a subclass TranslatedKeyEvent to be a non character event. | 574 // This allows a subclass TranslatedKeyEvent to be a non character event. |
| 568 void set_is_char(bool is_char) { is_char_ = is_char; } | 575 void set_is_char(bool is_char) { is_char_ = is_char; } |
| 569 | 576 |
| 570 private: | 577 private: |
| 578 // The VKEY_? key code for the key event. This key code represent the remapped | |
| 579 // key position. e.g. for French keyboard, when user press the key on the | |
| 580 // right side of TAB key, |key_code_| is VKEY_A, while |code_| is "KeyQ". | |
|
kpschoedel
2014/06/12 16:00:24
For non-Latin languages, it is the unmapped ("US")
Shu Chen
2014/06/13 02:07:15
Done. I've removed the comment here.
| |
| 571 KeyboardCode key_code_; | 581 KeyboardCode key_code_; |
| 572 | 582 |
| 573 // String of 'code' defined in DOM KeyboardEvent (e.g. 'KeyA', 'Space') | 583 // String of 'code' defined in DOM KeyboardEvent (e.g. 'KeyA', 'Space') |
| 574 // http://www.w3.org/TR/uievents/#keyboard-key-codes. | 584 // http://www.w3.org/TR/uievents/#keyboard-key-codes. |
| 575 // | 585 // |
| 576 // This value represents the physical position in the keyboard and can be | 586 // This value represents the physical position in the keyboard and can be |
| 577 // converted from / to keyboard scan code like XKB. | 587 // converted from / to keyboard scan code like XKB. |
| 578 std::string code_; | 588 std::string code_; |
| 579 | 589 |
| 580 // True if this is a translated character event (vs. a raw key down). Both | 590 // True if this is a translated character event (vs. a raw key down). Both |
| 581 // share the same type: ET_KEY_PRESSED. | 591 // share the same type: ET_KEY_PRESSED. |
| 582 bool is_char_; | 592 bool is_char_; |
| 583 | 593 |
| 594 // The platform related keycode value. For XKB, it's keysym value. | |
| 595 // For now, this is used for CharacterComposer in ChromeOS. | |
| 596 // Note: for XKB, the keysym vlaue is modifiered value. But for other | |
| 597 // platforms, it may be unmodifiered value. | |
| 598 uint32 platform_keycode_; | |
| 599 | |
| 600 // String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'â') | |
| 601 // http://www.w3.org/TR/uievents/#keyboard-key-codes. | |
| 602 // | |
| 603 // This value represents the text that the key event will insert to input | |
| 604 // field. For key with modifier key, it may have specifial text. | |
| 605 // e.g. CTRL+A has '\x01'. | |
| 584 uint16 character_; | 606 uint16 character_; |
| 585 | 607 |
| 586 static bool IsRepeated(const KeyEvent& event); | 608 static bool IsRepeated(const KeyEvent& event); |
| 587 | 609 |
| 588 static KeyEvent* last_key_event_; | 610 static KeyEvent* last_key_event_; |
| 589 }; | 611 }; |
| 590 | 612 |
| 591 class EVENTS_EXPORT ScrollEvent : public MouseEvent { | 613 class EVENTS_EXPORT ScrollEvent : public MouseEvent { |
| 592 public: | 614 public: |
| 593 explicit ScrollEvent(const base::NativeEvent& native_event); | 615 explicit ScrollEvent(const base::NativeEvent& native_event); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 // The set of indices of ones in the binary representation of | 692 // The set of indices of ones in the binary representation of |
| 671 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 693 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
| 672 // This value is stored as a bitfield because the number of touch ids varies, | 694 // This value is stored as a bitfield because the number of touch ids varies, |
| 673 // but we currently don't need more than 32 touches at a time. | 695 // but we currently don't need more than 32 touches at a time. |
| 674 const unsigned int touch_ids_bitfield_; | 696 const unsigned int touch_ids_bitfield_; |
| 675 }; | 697 }; |
| 676 | 698 |
| 677 } // namespace ui | 699 } // namespace ui |
| 678 | 700 |
| 679 #endif // UI_EVENTS_EVENT_H_ | 701 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |