| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_IME_INPUT_METHOD_IBUS_H_ | 5 #ifndef VIEWS_IME_INPUT_METHOD_IBUS_H_ |
| 6 #define VIEWS_IME_INPUT_METHOD_IBUS_H_ | 6 #define VIEWS_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> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // context. | 64 // context. |
| 65 class PendingCreateICRequest; | 65 class PendingCreateICRequest; |
| 66 | 66 |
| 67 // Overridden from InputMethodBase: | 67 // Overridden from InputMethodBase: |
| 68 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | 68 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 69 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; | 69 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE; |
| 70 | 70 |
| 71 // Creates |context_| instance asynchronously. | 71 // Creates |context_| instance asynchronously. |
| 72 void CreateContext(); | 72 void CreateContext(); |
| 73 | 73 |
| 74 // Sets |context_| or |fake_context_| and hooks necessary signals. | 74 // Sets |context_| and hooks necessary signals. |
| 75 void SetContext(IBusInputContext* ic, bool fake); | 75 void SetContext(IBusInputContext* ic); |
| 76 | 76 |
| 77 // Destroys |context_| instance. | 77 // Destroys |context_| instance. |
| 78 void DestroyContext(); | 78 void DestroyContext(); |
| 79 | 79 |
| 80 // Asks the client to confirm current composition text. | 80 // Asks the client to confirm current composition text. |
| 81 void ConfirmCompositionText(); | 81 void ConfirmCompositionText(); |
| 82 | 82 |
| 83 // Resets |context_| and abandon all pending results and key events. | 83 // Resets |context_| and abandon all pending results and key events. |
| 84 void ResetContext(); | 84 void ResetContext(); |
| 85 | 85 |
| 86 // Checks the availability of focused text input client and update focus state | 86 // Checks the availability of focused text input client and update focus state |
| 87 // of |context_| and |context_simple_| accordingly. | 87 // of |context_| and |context_simple_| accordingly. |
| 88 void UpdateContextFocusState(); | 88 void UpdateContextFocusState(); |
| 89 | 89 |
| 90 // Updates focus state of |fake_context_| accordingly. | |
| 91 void UpdateFakeContextFocusState(); | |
| 92 | |
| 93 // Process a key returned from the input method. | 90 // Process a key returned from the input method. |
| 94 void ProcessKeyEventPostIME(const KeyEvent& key, guint32 ibus_keycode, | 91 void ProcessKeyEventPostIME(const KeyEvent& key, guint32 ibus_keycode, |
| 95 bool handled); | 92 bool handled); |
| 96 | 93 |
| 97 // Processes a key event that was already filtered by the input method. | 94 // Processes a key event that was already filtered by the input method. |
| 98 // A VKEY_PROCESSKEY may be dispatched to the focused View. | 95 // A VKEY_PROCESSKEY may be dispatched to the focused View. |
| 99 void ProcessFilteredKeyPressEvent(const KeyEvent& key); | 96 void ProcessFilteredKeyPressEvent(const KeyEvent& key); |
| 100 | 97 |
| 101 // Processes a key event that was not filtered by the input method. | 98 // Processes a key event that was not filtered by the input method. |
| 102 void ProcessUnfilteredKeyPressEvent(const KeyEvent& key, | 99 void ProcessUnfilteredKeyPressEvent(const KeyEvent& key, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 130 IBusInputContext*, IBusText*); | 127 IBusInputContext*, IBusText*); |
| 131 CHROMEG_CALLBACK_3(InputMethodIBus, void, OnForwardKeyEvent, | 128 CHROMEG_CALLBACK_3(InputMethodIBus, void, OnForwardKeyEvent, |
| 132 IBusInputContext*, guint, guint, guint); | 129 IBusInputContext*, guint, guint, guint); |
| 133 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnShowPreeditText, | 130 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnShowPreeditText, |
| 134 IBusInputContext*); | 131 IBusInputContext*); |
| 135 CHROMEG_CALLBACK_3(InputMethodIBus, void, OnUpdatePreeditText, | 132 CHROMEG_CALLBACK_3(InputMethodIBus, void, OnUpdatePreeditText, |
| 136 IBusInputContext*, IBusText*, guint, gboolean); | 133 IBusInputContext*, IBusText*, guint, gboolean); |
| 137 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnHidePreeditText, | 134 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnHidePreeditText, |
| 138 IBusInputContext*); | 135 IBusInputContext*); |
| 139 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnDestroy, IBusInputContext*); | 136 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnDestroy, IBusInputContext*); |
| 140 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnFakeDestroy, IBusInputContext*); | |
| 141 | 137 |
| 142 // Event handlers for IBusBus: | 138 // Event handlers for IBusBus: |
| 143 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnIBusConnected, IBusBus*); | 139 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnIBusConnected, IBusBus*); |
| 144 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnIBusDisconnected, IBusBus*); | 140 CHROMEG_CALLBACK_0(InputMethodIBus, void, OnIBusDisconnected, IBusBus*); |
| 145 | 141 |
| 146 // Returns the global IBusBus instance. | 142 // Returns the global IBusBus instance. |
| 147 static IBusBus* GetIBus(); | 143 static IBusBus* GetIBus(); |
| 148 | 144 |
| 149 // Callback function for ibus_input_context_process_key_event_async(). | 145 // Callback function for ibus_input_context_process_key_event_async(). |
| 150 static void ProcessKeyEventDone(IBusInputContext* context, | 146 static void ProcessKeyEventDone(IBusInputContext* context, |
| 151 GAsyncResult* res, | 147 GAsyncResult* res, |
| 152 PendingKeyEvent* data); | 148 PendingKeyEvent* data); |
| 153 | 149 |
| 154 // Callback function for ibus_bus_create_input_context_async(). | 150 // Callback function for ibus_bus_create_input_context_async(). |
| 155 static void CreateInputContextDone(IBusBus* bus, | 151 static void CreateInputContextDone(IBusBus* bus, |
| 156 GAsyncResult* res, | 152 GAsyncResult* res, |
| 157 PendingCreateICRequest* data); | 153 PendingCreateICRequest* data); |
| 158 | 154 |
| 159 // The input context for actual text input. | 155 // The input context for actual text input. |
| 160 IBusInputContext* context_; | 156 IBusInputContext* context_; |
| 161 | 157 |
| 162 // The "fake" input context for hotkey handling, it is only used when there | |
| 163 // is no focused view, or it doesn't support text input. | |
| 164 IBusInputContext* fake_context_; | |
| 165 | |
| 166 // All pending key events. Note: we do not own these object, we just save | 158 // All pending key events. Note: we do not own these object, we just save |
| 167 // pointers to these object so that we can abandon them when necessary. | 159 // pointers to these object so that we can abandon them when necessary. |
| 168 // They will be deleted in ProcessKeyEventDone(). | 160 // They will be deleted in ProcessKeyEventDone(). |
| 169 std::set<PendingKeyEvent*> pending_key_events_; | 161 std::set<PendingKeyEvent*> pending_key_events_; |
| 170 | 162 |
| 171 // The pending request for creating the |context_| instance. We need to keep | 163 // The pending request for creating the |context_| instance. We need to keep |
| 172 // this pointer so that we can receive or abandon the result. | 164 // this pointer so that we can receive or abandon the result. |
| 173 PendingCreateICRequest* pending_create_ic_request_; | 165 PendingCreateICRequest* pending_create_ic_request_; |
| 174 | 166 |
| 175 // The pending request for creating the |context_| instance. We need to keep | |
| 176 // this pointer so that we can receive or abandon the result. | |
| 177 PendingCreateICRequest* pending_create_fake_ic_request_; | |
| 178 | |
| 179 // Pending composition text generated by the current pending key event. | 167 // Pending composition text generated by the current pending key event. |
| 180 // It'll be sent to the focused text input client as soon as we receive the | 168 // It'll be sent to the focused text input client as soon as we receive the |
| 181 // processing result of the pending key event. | 169 // processing result of the pending key event. |
| 182 ui::CompositionText composition_; | 170 ui::CompositionText composition_; |
| 183 | 171 |
| 184 // Pending result text generated by the current pending key event. | 172 // Pending result text generated by the current pending key event. |
| 185 // It'll be sent to the focused text input client as soon as we receive the | 173 // It'll be sent to the focused text input client as soon as we receive the |
| 186 // processing result of the pending key event. | 174 // processing result of the pending key event. |
| 187 string16 result_text_; | 175 string16 result_text_; |
| 188 | 176 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 202 // An object to compose a character from a sequence of key presses | 190 // An object to compose a character from a sequence of key presses |
| 203 // including dead key etc. | 191 // including dead key etc. |
| 204 ui::CharacterComposer character_composer_; | 192 ui::CharacterComposer character_composer_; |
| 205 | 193 |
| 206 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); | 194 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); |
| 207 }; | 195 }; |
| 208 | 196 |
| 209 } // namespace views | 197 } // namespace views |
| 210 | 198 |
| 211 #endif // VIEWS_IME_INPUT_METHOD_IBUS_H_ | 199 #endif // VIEWS_IME_INPUT_METHOD_IBUS_H_ |
| OLD | NEW |