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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 // TODO(msw): Additional work may be needed for analogues on other platforms. | 554 // TODO(msw): Additional work may be needed for analogues on other platforms. |
555 bool IsUnicodeKeyCode() const; | 555 bool IsUnicodeKeyCode() const; |
556 | 556 |
557 std::string code() const { return code_; } | 557 std::string code() const { return code_; } |
558 | 558 |
559 // Normalizes flags_ to make it Windows/Mac compatible. Since the way | 559 // Normalizes flags_ to make it Windows/Mac compatible. Since the way |
560 // of setting modifier mask on X is very different than Windows/Mac as shown | 560 // of setting modifier mask on X is very different than Windows/Mac as shown |
561 // in http://crbug.com/127142#c8, the normalization is necessary. | 561 // in http://crbug.com/127142#c8, the normalization is necessary. |
562 void NormalizeFlags(); | 562 void NormalizeFlags(); |
563 | 563 |
| 564 // Returns true if the key event has already been processed by an input method |
| 565 // and there is no need to pass the key event to the input method again. |
| 566 bool IsTranslated() const; |
| 567 // Marks this key event as translated or not translated. |
| 568 void SetTranslated(bool translated); |
| 569 |
564 protected: | 570 protected: |
565 // This allows a subclass TranslatedKeyEvent to be a non character event. | 571 // This allows a subclass TranslatedKeyEvent to be a non character event. |
566 void set_is_char(bool is_char) { is_char_ = is_char; } | 572 void set_is_char(bool is_char) { is_char_ = is_char; } |
567 | 573 |
568 private: | 574 private: |
569 KeyboardCode key_code_; | 575 KeyboardCode key_code_; |
570 | 576 |
571 // String of 'code' defined in DOM KeyboardEvent (e.g. 'KeyA', 'Space') | 577 // String of 'code' defined in DOM KeyboardEvent (e.g. 'KeyA', 'Space') |
572 // http://www.w3.org/TR/uievents/#keyboard-key-codes. | 578 // http://www.w3.org/TR/uievents/#keyboard-key-codes. |
573 // | 579 // |
574 // This value represents the physical position in the keyboard and can be | 580 // This value represents the physical position in the keyboard and can be |
575 // converted from / to keyboard scan code like XKB. | 581 // converted from / to keyboard scan code like XKB. |
576 std::string code_; | 582 std::string code_; |
577 | 583 |
578 // True if this is a translated character event (vs. a raw key down). Both | 584 // True if this is a translated character event (vs. a raw key down). Both |
579 // share the same type: ET_KEY_PRESSED. | 585 // share the same type: ET_KEY_PRESSED. |
580 bool is_char_; | 586 bool is_char_; |
581 | 587 |
582 uint16 character_; | 588 uint16 character_; |
583 }; | 589 }; |
584 | 590 |
585 // A key event which is translated by an input method (IME). | |
586 // For example, if an IME receives a KeyEvent(VKEY_SPACE), and it does not | |
587 // consume the key, the IME usually generates and dispatches a | |
588 // TranslatedKeyEvent(VKEY_SPACE) event. If the IME receives a KeyEvent and | |
589 // it does consume the event, it might dispatch a | |
590 // TranslatedKeyEvent(VKEY_PROCESSKEY) event as defined in the DOM spec. | |
591 class EVENTS_EXPORT TranslatedKeyEvent : public KeyEvent { | |
592 public: | |
593 TranslatedKeyEvent(const base::NativeEvent& native_event, bool is_char); | |
594 | |
595 // Used for synthetic events such as a VKEY_PROCESSKEY key event. | |
596 TranslatedKeyEvent(bool is_press, KeyboardCode key_code, int flags); | |
597 | |
598 explicit TranslatedKeyEvent(const KeyEvent& key_event); | |
599 | |
600 // Changes the type() of the object from ET_TRANSLATED_KEY_* to ET_KEY_* so | |
601 // that RenderWidgetHostViewAura and NativeWidgetAura could handle the event. | |
602 void ConvertToKeyEvent(); | |
603 | |
604 private: | |
605 DISALLOW_COPY_AND_ASSIGN(TranslatedKeyEvent); | |
606 }; | |
607 | |
608 class EVENTS_EXPORT ScrollEvent : public MouseEvent { | 591 class EVENTS_EXPORT ScrollEvent : public MouseEvent { |
609 public: | 592 public: |
610 explicit ScrollEvent(const base::NativeEvent& native_event); | 593 explicit ScrollEvent(const base::NativeEvent& native_event); |
611 template <class T> | 594 template <class T> |
612 ScrollEvent(const ScrollEvent& model, | 595 ScrollEvent(const ScrollEvent& model, |
613 T* source, | 596 T* source, |
614 T* target) | 597 T* target) |
615 : MouseEvent(model, source, target), | 598 : MouseEvent(model, source, target), |
616 x_offset_(model.x_offset_), | 599 x_offset_(model.x_offset_), |
617 y_offset_(model.y_offset_), | 600 y_offset_(model.y_offset_), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 // The set of indices of ones in the binary representation of | 670 // The set of indices of ones in the binary representation of |
688 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 671 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
689 // This value is stored as a bitfield because the number of touch ids varies, | 672 // This value is stored as a bitfield because the number of touch ids varies, |
690 // but we currently don't need more than 32 touches at a time. | 673 // but we currently don't need more than 32 touches at a time. |
691 const unsigned int touch_ids_bitfield_; | 674 const unsigned int touch_ids_bitfield_; |
692 }; | 675 }; |
693 | 676 |
694 } // namespace ui | 677 } // namespace ui |
695 | 678 |
696 #endif // UI_EVENTS_EVENT_H_ | 679 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |