Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: ui/base/ime/input_method_ibus.h

Issue 45733008: sk6_charactercomposer: Merged DispatchKeyEvent and its fabricated version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_delegate.h ('k') | ui/base/ime/input_method_ibus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_BASE_IME_INPUT_METHOD_IBUS_H_ 5 #ifndef UI_BASE_IME_INPUT_METHOD_IBUS_H_
6 #define UI_BASE_IME_INPUT_METHOD_IBUS_H_ 6 #define UI_BASE_IME_INPUT_METHOD_IBUS_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 23 matching lines...) Expand all
34 public chromeos::IBusInputContextHandlerInterface { 34 public chromeos::IBusInputContextHandlerInterface {
35 public: 35 public:
36 explicit InputMethodIBus(internal::InputMethodDelegate* delegate); 36 explicit InputMethodIBus(internal::InputMethodDelegate* delegate);
37 virtual ~InputMethodIBus(); 37 virtual ~InputMethodIBus();
38 38
39 // Overridden from InputMethod: 39 // Overridden from InputMethod:
40 virtual void OnFocus() OVERRIDE; 40 virtual void OnFocus() OVERRIDE;
41 virtual void OnBlur() OVERRIDE; 41 virtual void OnBlur() OVERRIDE;
42 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, 42 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
43 NativeEventResult* result) OVERRIDE; 43 NativeEventResult* result) OVERRIDE;
44 virtual bool DispatchKeyEvent( 44 virtual bool DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE;
45 const base::NativeEvent& native_key_event) OVERRIDE;
46 virtual bool DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; 45 virtual bool DispatchFabricatedKeyEvent(const ui::KeyEvent& event) OVERRIDE;
47 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; 46 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
48 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE; 47 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
49 virtual void CancelComposition(const TextInputClient* client) OVERRIDE; 48 virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
50 virtual std::string GetInputLocale() OVERRIDE; 49 virtual std::string GetInputLocale() OVERRIDE;
51 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; 50 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
52 virtual bool IsActive() OVERRIDE; 51 virtual bool IsActive() OVERRIDE;
53 virtual bool IsCandidatePopupOpen() const OVERRIDE; 52 virtual bool IsCandidatePopupOpen() const OVERRIDE;
54 53
55 protected: 54 protected:
56 // Converts |text| into CompositionText. 55 // Converts |text| into CompositionText.
57 void ExtractCompositionText(const chromeos::IBusText& text, 56 void ExtractCompositionText(const chromeos::IBusText& text,
58 uint32 cursor_position, 57 uint32 cursor_position,
59 CompositionText* out_composition) const; 58 CompositionText* out_composition) const;
60 59
61 // Process a key returned from the input method. 60 // Process a key returned from the input method.
62 virtual void ProcessKeyEventPostIME(const base::NativeEvent& native_key_event, 61 virtual void ProcessKeyEventPostIME(const ui::KeyEvent& event,
63 uint32 ibus_state,
64 bool handled); 62 bool handled);
65 63
66 // Converts |native_event| to ibus representation.
67 virtual void IBusKeyEventFromNativeKeyEvent(
68 const base::NativeEvent& native_event,
69 uint32* ibus_keyval,
70 uint32* ibus_keycode,
71 uint32* ibus_state);
72
73 // Resets context and abandon all pending results and key events. 64 // Resets context and abandon all pending results and key events.
74 void ResetContext(); 65 void ResetContext();
75 66
76 private: 67 private:
77 class PendingKeyEvent; 68 class PendingKeyEvent;
78 69
79 // Overridden from InputMethodBase: 70 // Overridden from InputMethodBase:
80 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, 71 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before,
81 TextInputClient* focused) OVERRIDE; 72 TextInputClient* focused) OVERRIDE;
82 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, 73 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
83 TextInputClient* focused) OVERRIDE; 74 TextInputClient* focused) OVERRIDE;
84 75
85 // Asks the client to confirm current composition text. 76 // Asks the client to confirm current composition text.
86 void ConfirmCompositionText(); 77 void ConfirmCompositionText();
87 78
88 // Checks the availability of focused text input client and update focus 79 // Checks the availability of focused text input client and update focus
89 // state. 80 // state.
90 void UpdateContextFocusState(); 81 void UpdateContextFocusState();
91 82
92 // Processes a key event that was already filtered by the input method. 83 // Processes a key event that was already filtered by the input method.
93 // A VKEY_PROCESSKEY may be dispatched to the focused View. 84 // A VKEY_PROCESSKEY may be dispatched to the focused View.
94 void ProcessFilteredKeyPressEvent(const base::NativeEvent& native_key_event); 85 void ProcessFilteredKeyPressEvent(const ui::KeyEvent& key_event);
95 86
96 // Processes a key event that was not filtered by the input method. 87 // Processes a key event that was not filtered by the input method.
97 void ProcessUnfilteredKeyPressEvent(const base::NativeEvent& native_key_event, 88 void ProcessUnfilteredKeyPressEvent(const ui::KeyEvent& key_event);
98 uint32 ibus_state);
99 void ProcessUnfilteredFabricatedKeyPressEvent(EventType type,
100 KeyboardCode key_code,
101 int event_flags);
102 89
103 // Sends input method result caused by the given key event to the focused text 90 // Sends input method result caused by the given key event to the focused text
104 // input client. 91 // input client.
105 void ProcessInputMethodResult(const base::NativeEvent& native_key_event, 92 void ProcessInputMethodResult(const ui::KeyEvent& key_event, bool handled);
106 bool filtered);
107 93
108 // Checks if the pending input method result needs inserting into the focused 94 // Checks if the pending input method result needs inserting into the focused
109 // text input client as a single character. 95 // text input client as a single character.
110 bool NeedInsertChar() const; 96 bool NeedInsertChar() const;
111 97
112 // Checks if there is pending input method result. 98 // Checks if there is pending input method result.
113 bool HasInputMethodResult() const; 99 bool HasInputMethodResult() const;
114 100
115 // Abandons all pending key events. It usually happends when we lose keyboard 101 // Abandons all pending key events. It usually happends when we lose keyboard
116 // focus, the text input type is changed or we are destroyed. 102 // focus, the text input type is changed or we are destroyed.
117 void AbandonAllPendingKeyEvents(); 103 void AbandonAllPendingKeyEvents();
118 104
119 // Passes keyevent and executes character composition if necessary. Returns 105 // Passes keyevent and executes character composition if necessary. Returns
120 // true if character composer comsumes key event. 106 // true if character composer comsumes key event.
121 bool ExecuteCharacterComposer(uint32 ibus_keyval, 107 bool ExecuteCharacterComposer(const ui::KeyEvent& event);
122 uint32 ibus_keycode,
123 uint32 ibus_state);
124 108
125 // chromeos::IBusInputContextHandlerInterface overrides: 109 // chromeos::IBusInputContextHandlerInterface overrides:
126 virtual void CommitText(const std::string& text) OVERRIDE; 110 virtual void CommitText(const std::string& text) OVERRIDE;
127 virtual void ForwardKeyEvent(uint32 keyval, 111 virtual void ForwardKeyEvent(uint32 keyval,
128 uint32 keycode, 112 uint32 keycode,
129 uint32 state) OVERRIDE; 113 uint32 state) OVERRIDE;
130 virtual void ShowPreeditText() OVERRIDE; 114 virtual void ShowPreeditText() OVERRIDE;
131 virtual void HidePreeditText() OVERRIDE; 115 virtual void HidePreeditText() OVERRIDE;
132 virtual void UpdatePreeditText(const chromeos::IBusText& text, 116 virtual void UpdatePreeditText(const chromeos::IBusText& text,
133 uint32 cursor_pos, 117 uint32 cursor_pos,
134 bool visible) OVERRIDE; 118 bool visible) OVERRIDE;
135 virtual void DeleteSurroundingText(int32 offset, uint32 length) OVERRIDE; 119 virtual void DeleteSurroundingText(int32 offset, uint32 length) OVERRIDE;
136 120
137 void ProcessKeyEventDone(uint32 id, XEvent* xevent, 121 // Callback function for IBusEngineHandlerInterface::ProcessKeyEvent.
138 uint32 ibus_keyval, uint32 ibus_keycode, 122 void ProcessKeyEventDone(uint32 id, ui::KeyEvent* key_event, bool is_handled);
139 uint32 ibus_state, bool is_handled);
140 123
141 // Processes a caret bounds changed event. 124 // Processes a caret bounds changed event.
142 void OnCaretBoundsChangedInternal(const TextInputClient* client); 125 void OnCaretBoundsChangedInternal(const TextInputClient* client);
143 126
144 // All pending key events. Note: we do not own these object, we just save 127 // All pending key events. Note: we do not own these object, we just save
145 // pointers to these object so that we can abandon them when necessary. 128 // pointers to these object so that we can abandon them when necessary.
146 // They will be deleted in ProcessKeyEventDone(). 129 // They will be deleted in ProcessKeyEventDone().
147 std::set<uint32> pending_key_events_; 130 std::set<uint32> pending_key_events_;
148 131
149 // Pending composition text generated by the current pending key event. 132 // Pending composition text generated by the current pending key event.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 166
184 // Used for making callbacks. 167 // Used for making callbacks.
185 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; 168 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_;
186 169
187 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); 170 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus);
188 }; 171 };
189 172
190 } // namespace ui 173 } // namespace ui
191 174
192 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ 175 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_delegate.h ('k') | ui/base/ime/input_method_ibus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698