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

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, 6 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
« no previous file with comments | « ui/base/ime/input_method_chromeos.h ('k') | ui/wm/core/input_method_event_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « ui/base/ime/input_method_chromeos.h ('k') | ui/wm/core/input_method_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698