char* text = static_cast<char*>(event_info);
std::u16string text16 = base::UTF8ToUTF16(text);
- SendFakeCompositionKeyEvent(text16);
-
+ SendFakeKeyDownEvent();
LOG(INFO) << "OnCommit, text: " << text16;
ime_delegate_->OnCommit(text16);
+ SendFakeKeyUpEvent();
}
-void IMContextEfl::SendFakeCompositionKeyEvent(const std::u16string& buf) {
- std::string str = base::UTF16ToUTF8(buf);
-
-#if BUILDFLAG(IS_TIZEN_TV)
- // We should process both " " and "space" which IME sends.
- // Otherwise " " would be received by engine and cause unnecessary page
- // scroll.
- if (str == " ")
- str = "space";
-#endif
-
- Evas_Event_Key_Down downEvent;
- memset(&downEvent, 0, sizeof(Evas_Event_Key_Down));
- downEvent.key = str.c_str();
- downEvent.string = str.c_str();
-
- KeyEvent event = MakeWebKeyEvent(true, &downEvent);
- event.is_system_key = true;
-
- // Key code should be '229' except ASCII key event about key down/up event.
- // It is according to Web spec about key code [1].
- // On TV WebAPPs case, key code should be '229' including ASCII key event
- // about key down/up event.
- // [1] https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/
- // keyCode-spec.html
- // [2] http://developer.samsung.com/tv/develop/tutorials/user-input/
- // text-input-ime-external-keyboard
- if (event.key_code() == 0)
- event.set_key_code(static_cast<KeyboardCode>(229));
-
-#if BUILDFLAG(IS_TIZEN_TV)
- if (blink::IsTIZENWRT()) {
- // a-z, A-Z, 0-9
- int key_code = event.key_code();
- if ((key_code >= 65 && key_code <= 90) ||
- (key_code >= 48 && key_code <= 57)) {
- event.set_key_code(static_cast<KeyboardCode>(229));
- }
- }
-#endif
+void IMContextEfl::SendFakeKeyDownEvent() {
+ KeyEvent event(ET_KEY_PRESSED, static_cast<KeyboardCode>(229), EF_NONE,
+ base::TimeTicks());
#if BUILDFLAG(IS_TIZEN_TV)
// Needed for HBBTV single window, multiwebview scenario.
EflPlatformEventSource::GetInstance()->DispatchEflEvent(&event);
}
-void IMContextEfl::ProcessKeyUpEvent(KeyboardCode code) {
- KeyEvent event(ET_KEY_RELEASED, code, EF_NONE, base::TimeTicks());
+void IMContextEfl::SendFakeKeyUpEvent() {
+ KeyEvent event(ET_KEY_RELEASED, static_cast<KeyboardCode>(229), EF_NONE,
+ base::TimeTicks());
#if BUILDFLAG(IS_TIZEN_TV)
// Needed for HBBTV single window, multiwebview scenario.
void IMContextEfl::SetComposition(const char* buffer) {
std::u16string text16 = base::UTF8ToUTF16(buffer);
- if (!text16.empty())
- SendFakeCompositionKeyEvent(text16.substr(text16.length() - 1));
- else
- SendFakeCompositionKeyEvent(text16);
+ SendFakeKeyDownEvent();
composition_ = CompositionText();
composition_.text = text16;
free(buffer);
ime_delegate_->OnPreeditChanged(composition_);
+
+ SendFakeKeyUpEvent();
}
// TODO(kbalazs): figure out what do we need from these callbacks.