From 61f8323c298afa8ba745c1c1e2b991af5901e750 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 10 Feb 2022 11:50:16 +0900 Subject: [PATCH 1/2] Handle the key-up event in text_input_channel * Long press event was recently added to the input panel of VD. So we have to handle the key-up event appropriately. Signed-off-by: Boram Bae --- .../tizen/channels/text_input_channel.cc | 13 +++-- .../tizen/channels/text_input_channel.h | 2 +- .../tizen/tizen_input_method_context.cc | 57 ++++++++++++------- .../tizen/tizen_input_method_context.h | 2 +- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index dfd6ad64c16cd..293fb328608c5 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -124,12 +124,14 @@ 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)) { - HandleUnfilteredEvent(key); + if (!FilterEvent(key, is_down)) { + if (is_down) { + HandleUnfilteredEvent(key); + } } return true; @@ -314,7 +316,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 +341,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(); From 6912ad99eb83ef3de5534b3e1998f6debcfa1566 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 10 Feb 2022 14:35:03 +0900 Subject: [PATCH 2/2] Update based on review Signed-off-by: Boram Bae --- shell/platform/tizen/channels/text_input_channel.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 293fb328608c5..12fd1a6c27e82 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -128,10 +128,8 @@ bool TextInputChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { return false; } - if (!FilterEvent(key, is_down)) { - if (is_down) { - HandleUnfilteredEvent(key); - } + if (!FilterEvent(key, is_down) && is_down) { + HandleUnfilteredEvent(key); } return true;