diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index 10c5dd6bbd5c0..f17cbec837295 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -62,6 +62,25 @@ uint64_t GetLogicalKey(const char* key) { return ApplyPlaneToId(0, kTizenPlane); } +uint32_t GetFallbackScanCodeFromKey(const std::string& key) { + // Some of scan codes are 0 when key events occur from the software + // keyboard, and key_event_channel cannot handle the key events. + // To avoid this, use a valid scan code. + + // The following keys can be emitted from the software keyboard and have a + // scan code with 0 value. + const std::map kKeyToScanCode = { + {"BackSpace", 0x00000016}, {"Up", 0x0000006f}, {"Left", 0x00000071}, + {"Right", 0x00000072}, {"Down", 0x00000074}, + }; + + auto iter = kKeyToScanCode.find(key); + if (iter != kKeyToScanCode.end()) { + return iter->second; + } + return 0; +} + } // namespace KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger, @@ -99,6 +118,10 @@ void KeyEventChannel::SendKey(const char* key, } pending_events_[sequence_id] = std::make_unique(pending); + if (scan_code == 0) { + scan_code = GetFallbackScanCodeFromKey(key); + } + SendEmbedderEvent(key, string, compose, modifiers, scan_code, is_down, sequence_id); // The channel-based API (RawKeyEvent) is deprecated and |SendChannelEvent| diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 335001b4104bb..52a9c0f411690 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -303,43 +303,11 @@ void TextInputChannel::SendStateUpdate() { bool TextInputChannel::HandleKey(const char* key, const char* string, uint32_t modifires) { - bool shift = modifires & ECORE_SHIFT; bool needs_update = false; std::string key_str = key; - if (key_str == "Left") { - if (shift) { - TextRange selection = active_model_->selection(); - needs_update = active_model_->SetSelection( - TextRange(selection.base(), selection.extent() - 1)); - } else { - needs_update = active_model_->MoveCursorBack(); - } - } else if (key_str == "Right") { - if (shift) { - TextRange selection = active_model_->selection(); - needs_update = active_model_->SetSelection( - TextRange(selection.base(), selection.extent() + 1)); - } else { - needs_update = active_model_->MoveCursorForward(); - } - } else if (key_str == "End") { - if (shift) { - needs_update = active_model_->SelectToEnd(); - } else { - needs_update = active_model_->MoveCursorToEnd(); - } - } else if (key_str == "Home") { - if (shift) { - needs_update = active_model_->SelectToBeginning(); - } else { - needs_update = active_model_->MoveCursorToBeginning(); - } - } else if (key_str == "BackSpace") { - needs_update = active_model_->Backspace(); - } else if (key_str == "Delete") { - needs_update = active_model_->Delete(); - } else if (string && strlen(string) == 1 && IsAsciiPrintableKey(string[0])) { + if (string && strlen(string) == 1 && IsAsciiPrintableKey(string[0])) { + // This is a fallback for printable keys not handled by IMF. active_model_->AddCodePoint(string[0]); needs_update = true; } else if (key_str == "Return") { diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 72d7282d74486..875d94b4aa1d8 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -347,13 +347,14 @@ void TizenInputMethodContext::SetInputPanelOptions() { } bool TizenInputMethodContext::ShouldIgnoreKey(std::string key, bool is_ime) { - // The keys below should be handled in the text_input_channel. + // The below keys should be handled by the flutter framework. if (is_ime && (key == "Left" || key == "Right" || key == "Up" || key == "Down" || key == "End" || key == "Home" || key == "BackSpace" || key == "Delete")) { return true; } #ifdef TV_PROFILE + // The Select key should be handled in the TextInputChannel. if (is_ime && key == "Select") { return true; } diff --git a/shell/platform/tizen/tizen_view_elementary.cc b/shell/platform/tizen/tizen_view_elementary.cc index 0ce00510351c5..37c8fd8e5ed0d 100644 --- a/shell/platform/tizen/tizen_view_elementary.cc +++ b/shell/platform/tizen/tizen_view_elementary.cc @@ -215,7 +215,7 @@ void TizenViewElementary::RegisterEventHandlers() { if (self->view_) { if (self->event_layer_ == object) { auto* key_event = reinterpret_cast(event_info); - int handled = false; + bool handled = false; key_event->event_flags = Evas_Event_Flags(key_event->event_flags | EVAS_EVENT_FLAG_ON_HOLD); if (self->input_method_context_->IsInputPanelShown()) { @@ -241,7 +241,7 @@ void TizenViewElementary::RegisterEventHandlers() { if (self->view_) { if (self->event_layer_ == object) { auto* key_event = reinterpret_cast(event_info); - int handled = false; + bool handled = false; key_event->event_flags = Evas_Event_Flags(key_event->event_flags | EVAS_EVENT_FLAG_ON_HOLD); if (self->input_method_context_->IsInputPanelShown()) { diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 5b71816898716..edcef9fc4a5bd 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -313,7 +313,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - int handled = false; + bool handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = self->input_method_context_->HandleEcoreEventKey( key_event, true); @@ -337,7 +337,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - int handled = false; + bool handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = self->input_method_context_->HandleEcoreEventKey( key_event, false); diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index 21397b4ef1a60..43d8dc0d5e84d 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -238,7 +238,7 @@ void TizenWindowElementary::RegisterEventHandlers() { if (self->view_) { if (self->elm_win_ == object) { auto* key_event = reinterpret_cast(event_info); - int handled = false; + bool handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = self->input_method_context_->HandleEvasEventKeyDown(key_event); @@ -262,7 +262,7 @@ void TizenWindowElementary::RegisterEventHandlers() { if (self->view_) { if (self->elm_win_ == object) { auto* key_event = reinterpret_cast(event_info); - int handled = false; + bool handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = self->input_method_context_->HandleEvasEventKeyUp(key_event);