Chromium Code Reviews| Index: ui/base/ime/input_method_chromeos.cc |
| diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc |
| index c951b4398489902ea3706c2236b476345d9f8e7b..04a68df50b543a7ed4b3fa099c703456588775e5 100644 |
| --- a/ui/base/ime/input_method_chromeos.cc |
| +++ b/ui/base/ime/input_method_chromeos.cc |
| @@ -438,6 +438,19 @@ bool InputMethodChromeOS::HasInputMethodResult() const { |
| return result_text_.length() || composition_changed_; |
| } |
| +void InputMethodChromeOS::SendFakeProcessKeyEvent(bool pressed) const { |
| + if (!GetTextInputClient()) |
| + return; |
| + KeyEvent evt(pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, |
| + pressed ? VKEY_PROCESSKEY : VKEY_UNKNOWN, |
| + EF_IME_FABRICATED_KEY, |
| + false); // is_char |
| + Event::DispatcherApi dispatch_helper(&evt); |
| + dispatch_helper.set_target(reinterpret_cast<EventTarget*>( |
| + GetTextInputClient()->GetAttachedWindow())); |
|
oshima
2014/06/05 15:03:13
As I said, it is my understanding that DispatherAp
sadrul
2014/06/05 15:46:28
Indeed. You should not use this here.
Shu Chen
2014/06/05 16:26:54
Done.
Shu Chen
2014/06/05 16:26:54
Done.
|
| + DispatchKeyEventPostIME(evt); |
| +} |
| + |
| void InputMethodChromeOS::AbandonAllPendingKeyEvents() { |
| pending_key_events_.clear(); |
| } |
| @@ -463,7 +476,9 @@ void InputMethodChromeOS::CommitText(const std::string& text) { |
| // If we are not handling key event, do not bother sending text result if the |
| // focused text input client does not support text input. |
| if (pending_key_events_.empty() && !IsTextInputTypeNone()) { |
| + SendFakeProcessKeyEvent(true); |
| GetTextInputClient()->InsertText(utf16_text); |
| + SendFakeProcessKeyEvent(false); |
| result_text_.clear(); |
| } |
| } |
| @@ -505,7 +520,9 @@ void InputMethodChromeOS::UpdateCompositionText( |
| // If we receive a composition text without pending key event, then we need to |
| // send it to the focused text input client directly. |
| if (pending_key_events_.empty()) { |
| + SendFakeProcessKeyEvent(true); |
| GetTextInputClient()->SetCompositionText(composition_); |
| + SendFakeProcessKeyEvent(false); |
| composition_changed_ = false; |
| composition_.Clear(); |
| } |
| @@ -521,8 +538,11 @@ void InputMethodChromeOS::HidePreeditText() { |
| if (pending_key_events_.empty()) { |
| TextInputClient* client = GetTextInputClient(); |
| - if (client && client->HasCompositionText()) |
| + if (client && client->HasCompositionText()) { |
| + SendFakeProcessKeyEvent(true); |
| client->ClearCompositionText(); |
| + SendFakeProcessKeyEvent(false); |
| + } |
| composition_changed_ = false; |
| } |
| } |