diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index dfd6ad64c16cd..12fd1a6c27e82 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -124,11 +124,11 @@ TextInputChannel::TextInputChannel( TextInputChannel::~TextInputChannel() {} bool TextInputChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { - if (!active_model_ || !is_down) { + if (!active_model_) { return false; } - if (!FilterEvent(key)) { + if (!FilterEvent(key, is_down) && is_down) { HandleUnfilteredEvent(key); } @@ -314,7 +314,7 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) { channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args)); } -bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) { +bool TextInputChannel::FilterEvent(Ecore_Event_Key* event, bool is_down) { bool handled = false; #if defined(__X64_SHELL__) @@ -339,7 +339,8 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) { return false; } - handled = input_method_context_->FilterEvent(event, is_ime ? "ime" : ""); + handled = + input_method_context_->FilterEvent(event, is_ime ? "ime" : "", is_down); #ifdef WEARABLE_PROFILE if (!handled && !strcmp(event->key, "Return") && diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 2d98295ca77fa..746bd6b6067a6 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -43,7 +43,7 @@ class TextInputChannel { const MethodCall& method_call, std::unique_ptr> result); void SendStateUpdate(const TextInputModel& model); - bool FilterEvent(Ecore_Event_Key* event); + bool FilterEvent(Ecore_Event_Key* event, bool is_down); void HandleUnfilteredEvent(Ecore_Event_Key* event); void EnterPressed(TextInputModel* model, bool select); void ResetTextEditingContext() { diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 019d0b2333f06..5c5dcda76252a 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -20,7 +20,7 @@ const char* GetEcoreImfContextAvailableId() { return nullptr; } -Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreIMFInputPanelLayout( +Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreImfInputPanelLayout( const std::string& text_input_type) { if (text_input_type == "TextInputType.text" || text_input_type == "TextInputType.multiline") { @@ -44,7 +44,7 @@ Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreIMFInputPanelLayout( } } -Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreIMFModifiers( +Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreImfModifiers( unsigned int ecore_modifiers) { unsigned int modifiers(ECORE_IMF_KEYBOARD_MODIFIER_NONE); if (ecore_modifiers & ECORE_EVENT_MODIFIER_SHIFT) { @@ -65,7 +65,7 @@ Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreIMFModifiers( return static_cast(modifiers); } -Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreIMFLocks( +Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreImfLocks( unsigned int modifiers) { // If no other matches, returns NONE. unsigned int locks(ECORE_IMF_KEYBOARD_LOCK_NONE); @@ -81,6 +81,24 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreIMFLocks( return static_cast(locks); } +template +T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { + T imf_event; + + imf_event.keyname = event->keyname; + imf_event.key = event->key; + imf_event.string = event->string; + imf_event.compose = event->compose; + imf_event.timestamp = event->timestamp; + imf_event.modifiers = + EcoreInputModifiersToEcoreImfModifiers(event->modifiers); + imf_event.locks = EcoreInputModifiersToEcoreImfLocks(event->modifiers); + imf_event.dev_name = dev_name; + imf_event.keycode = event->keycode; + + return imf_event; +} + } // namespace namespace flutter { @@ -125,26 +143,25 @@ TizenInputMethodContext::~TizenInputMethodContext() { } bool TizenInputMethodContext::FilterEvent(Ecore_Event_Key* event, - const char* dev_name) { + const char* dev_name, + bool is_down) { FT_ASSERT(imf_context_); FT_ASSERT(event); FT_ASSERT(dev_name); - Ecore_IMF_Event_Key_Down imf_event; - imf_event.keyname = event->keyname; - imf_event.key = event->key; - imf_event.string = event->string; - imf_event.compose = event->compose; - imf_event.timestamp = event->timestamp; - imf_event.modifiers = - EcoreInputModifiersToEcoreIMFModifiers(event->modifiers); - imf_event.locks = EcoreInputModifiersToEcoreIMFLocks(event->modifiers); - imf_event.dev_name = dev_name; - imf_event.keycode = event->keycode; - - return ecore_imf_context_filter_event( - imf_context_, ECORE_IMF_EVENT_KEY_DOWN, - reinterpret_cast(&imf_event)); + if (is_down) { + auto imf_event = + EcoreEventKeyToEcoreImfEvent(event, dev_name); + return ecore_imf_context_filter_event( + imf_context_, ECORE_IMF_EVENT_KEY_DOWN, + reinterpret_cast(&imf_event)); + } else { + auto imf_event = + EcoreEventKeyToEcoreImfEvent(event, dev_name); + return ecore_imf_context_filter_event( + imf_context_, ECORE_IMF_EVENT_KEY_UP, + reinterpret_cast(&imf_event)); + } } InputPanelGeometry TizenInputMethodContext::GetInputPanelGeometry() { @@ -175,7 +192,7 @@ void TizenInputMethodContext::HideInputPanel() { void TizenInputMethodContext::SetInputPanelLayout( const std::string& input_type) { FT_ASSERT(imf_context_); - auto panel_layout = TextInputTypeToEcoreIMFInputPanelLayout(input_type); + auto panel_layout = TextInputTypeToEcoreImfInputPanelLayout(input_type); ecore_imf_context_input_panel_layout_set(imf_context_, panel_layout); } diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index e353fe1f9d677..18febbeac1754 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -32,7 +32,7 @@ class TizenInputMethodContext { TizenInputMethodContext(FlutterTizenEngine* engine); ~TizenInputMethodContext(); - bool FilterEvent(Ecore_Event_Key* event, const char* dev_name); + bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); InputPanelGeometry GetInputPanelGeometry();