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

Unified Diff: ui/base/ime/input_method_chromeos.cc

Issue 298893003: Supports fake key events for setComposition/commitText by on-screen keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ... Created 6 years, 7 months 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 side-by-side diff with in-line comments
Download patch
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..8bea1390b82f25a458c0861e08118778eb647879 100644
--- a/ui/base/ime/input_method_chromeos.cc
+++ b/ui/base/ime/input_method_chromeos.cc
@@ -438,6 +438,14 @@ bool InputMethodChromeOS::HasInputMethodResult() const {
return result_text_.length() || composition_changed_;
}
+void InputMethodChromeOS::SendFakeProcessKeyEvent(bool pressed) const {
+ KeyEvent evt(pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED,
+ pressed ? VKEY_PROCESSKEY : VKEY_UNKNOWN,
+ EF_IME_FABRICATED_KEY,
+ false); // is_char
+ DispatchKeyEventPostIME(evt);
+}
+
void InputMethodChromeOS::AbandonAllPendingKeyEvents() {
pending_key_events_.clear();
}
@@ -463,7 +471,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 +515,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 +533,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;
}
}

Powered by Google App Engine
This is Rietveld 408576698