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_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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "ui/base/ime/character_composer.h" | 16 #include "ui/base/ime/character_composer.h" |
17 #include "ui/base/ime/composition_text.h" | 17 #include "ui/base/ime/composition_text.h" |
18 #include "ui/base/ime/ibus_client.h" | 18 #include "ui/base/ime/ibus_client.h" |
19 #include "ui/base/ime/input_method_base.h" | 19 #include "ui/base/ime/input_method_base.h" |
20 | 20 |
21 namespace dbus { | |
22 class ObjectPath; | |
23 }; | |
Yusuke Sato
2012/06/25 13:41:33
remove ;
Seigo Nonaka
2012/06/28 03:43:03
Done.
| |
21 namespace chromeos { | 24 namespace chromeos { |
22 namespace ibus { | 25 namespace ibus { |
23 class IBusText; | 26 class IBusText; |
24 } // namespace ibus | 27 } // namespace ibus |
25 } // namespace chromeos | 28 } // namespace chromeos |
26 | 29 |
27 namespace ui { | 30 namespace ui { |
28 | 31 |
29 // A ui::InputMethod implementation based on IBus. | 32 // A ui::InputMethod implementation based on IBus. |
30 class UI_EXPORT InputMethodIBus : public InputMethodBase { | 33 class UI_EXPORT InputMethodIBus : public InputMethodBase { |
(...skipping 27 matching lines...) Expand all Loading... | |
58 // The caller is not allowed to delete the object. | 61 // The caller is not allowed to delete the object. |
59 internal::IBusClient* ibus_client() const; | 62 internal::IBusClient* ibus_client() const; |
60 | 63 |
61 protected: | 64 protected: |
62 // Converts |text| into CompositionText. | 65 // Converts |text| into CompositionText. |
63 void ExtractCompositionText(const chromeos::ibus::IBusText& text, | 66 void ExtractCompositionText(const chromeos::ibus::IBusText& text, |
64 uint32 cursor_position, | 67 uint32 cursor_position, |
65 CompositionText* out_composition) const; | 68 CompositionText* out_composition) const; |
66 | 69 |
67 private: | 70 private: |
68 class PendingKeyEventImpl; | 71 class PendingKeyEvent; |
69 class PendingCreateICRequestImpl; | 72 class PendingCreateICRequest; |
70 | 73 |
71 // Overridden from InputMethodBase: | 74 // Overridden from InputMethodBase: |
72 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, | 75 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, |
73 TextInputClient* focused) OVERRIDE; | 76 TextInputClient* focused) OVERRIDE; |
74 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, | 77 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, |
75 TextInputClient* focused) OVERRIDE; | 78 TextInputClient* focused) OVERRIDE; |
76 | 79 |
77 // Creates context asynchronously. | 80 // Creates context asynchronously. |
78 void CreateContext(); | 81 void CreateContext(); |
79 | 82 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 | 124 |
122 // Checks if there is pending input method result. | 125 // Checks if there is pending input method result. |
123 bool HasInputMethodResult() const; | 126 bool HasInputMethodResult() const; |
124 | 127 |
125 // Fabricates a key event with VKEY_PROCESSKEY key code and dispatches it to | 128 // Fabricates a key event with VKEY_PROCESSKEY key code and dispatches it to |
126 // the focused View. | 129 // the focused View. |
127 void SendFakeProcessKeyEvent(bool pressed) const; | 130 void SendFakeProcessKeyEvent(bool pressed) const; |
128 | 131 |
129 // Called when a pending key event has finished. The event will be removed | 132 // Called when a pending key event has finished. The event will be removed |
130 // from |pending_key_events_|. | 133 // from |pending_key_events_|. |
131 void FinishPendingKeyEvent(PendingKeyEventImpl* pending_key); | 134 void FinishPendingKeyEvent(PendingKeyEvent* pending_key); |
132 | 135 |
133 // Abandons all pending key events. It usually happends when we lose keyboard | 136 // Abandons all pending key events. It usually happends when we lose keyboard |
134 // focus, the text input type is changed or we are destroyed. | 137 // focus, the text input type is changed or we are destroyed. |
135 void AbandonAllPendingKeyEvents(); | 138 void AbandonAllPendingKeyEvents(); |
136 | 139 |
137 // Releases context focus and confirms the composition text. Then destroy | 140 // Releases context focus and confirms the composition text. Then destroy |
138 // object proxy. | 141 // object proxy. |
139 void ResetInputContext(); | 142 void ResetInputContext(); |
140 | 143 |
144 // Returns true if the connection to ibus-daemon is established. | |
145 bool IsConnected(); | |
146 | |
147 // Returns true if the input context is ready to use. | |
148 bool IsContextReady(); | |
149 | |
141 // Event handlers for IBusInputContext: | 150 // Event handlers for IBusInputContext: |
142 void OnCommitText(const chromeos::ibus::IBusText& text); | 151 void OnCommitText(const chromeos::ibus::IBusText& text); |
143 void OnForwardKeyEvent(uint32 keyval, uint32 keycode, uint32 status); | 152 void OnForwardKeyEvent(uint32 keyval, uint32 keycode, uint32 status); |
144 void OnShowPreeditText(); | 153 void OnShowPreeditText(); |
145 void OnUpdatePreeditText(const chromeos::ibus::IBusText& text, | 154 void OnUpdatePreeditText(const chromeos::ibus::IBusText& text, |
146 uint32 cursor_pos, | 155 uint32 cursor_pos, |
147 bool visible); | 156 bool visible); |
148 void OnHidePreeditText(); | 157 void OnHidePreeditText(); |
149 | 158 |
150 void CreateInputContextDone(PendingCreateICRequestImpl* ic_request, | 159 void CreateInputContextDone(PendingCreateICRequest* ic_request, |
151 const dbus::ObjectPath& object_path); | 160 const dbus::ObjectPath& object_path); |
152 static void ProcessKeyEventDone(PendingKeyEventImpl* pending_key_event, | 161 void CreateInputContextFail(PendingCreateICRequest* ic_request); |
162 static void ProcessKeyEventDone(PendingKeyEvent* pending_key_event, | |
153 bool is_handled); | 163 bool is_handled); |
154 | 164 |
155 scoped_ptr<internal::IBusClient> ibus_client_; | 165 scoped_ptr<internal::IBusClient> ibus_client_; |
156 | 166 |
157 // All pending key events. Note: we do not own these object, we just save | 167 // All pending key events. Note: we do not own these object, we just save |
158 // pointers to these object so that we can abandon them when necessary. | 168 // pointers to these object so that we can abandon them when necessary. |
159 // They will be deleted in ProcessKeyEventDone(). | 169 // They will be deleted in ProcessKeyEventDone(). |
160 std::set<PendingKeyEventImpl*> pending_key_events_; | 170 std::set<PendingKeyEvent*> pending_key_events_; |
161 | 171 |
162 // The pending request for creating the input context. We need to keep this | 172 // The pending request for creating the input context. We need to keep this |
163 // pointer so that we can receive or abandon the result. | 173 // pointer so that we can receive or abandon the result. |
164 PendingCreateICRequestImpl* pending_create_ic_request_; | 174 PendingCreateICRequest* pending_create_ic_request_; |
165 | 175 |
166 // Pending composition text generated by the current pending key event. | 176 // Pending composition text generated by the current pending key event. |
167 // It'll be sent to the focused text input client as soon as we receive the | 177 // It'll be sent to the focused text input client as soon as we receive the |
168 // processing result of the pending key event. | 178 // processing result of the pending key event. |
169 CompositionText composition_; | 179 CompositionText composition_; |
170 | 180 |
171 // Pending result text generated by the current pending key event. | 181 // Pending result text generated by the current pending key event. |
172 // It'll be sent to the focused text input client as soon as we receive the | 182 // It'll be sent to the focused text input client as soon as we receive the |
173 // processing result of the pending key event. | 183 // processing result of the pending key event. |
174 string16 result_text_; | 184 string16 result_text_; |
(...skipping 17 matching lines...) Expand all Loading... | |
192 | 202 |
193 // Used for making callbacks. | 203 // Used for making callbacks. |
194 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; | 204 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; |
195 | 205 |
196 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); | 206 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); |
197 }; | 207 }; |
198 | 208 |
199 } // namespace ui | 209 } // namespace ui |
200 | 210 |
201 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ | 211 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ |
OLD | NEW |