From b469a7f0c6adb59aba8bd7ed055e7e6c40a10525 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 6 May 2022 19:56:53 +0900 Subject: [PATCH 01/12] Update text input channel based on compose methods Signed-off-by: Boram Bae --- .../tizen/channels/text_input_channel.cc | 101 ++++++++++-------- .../tizen/channels/text_input_channel.h | 34 ++++++ 2 files changed, 92 insertions(+), 43 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 0c75b04f18ef5..e60c2743f2c50 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -63,61 +63,76 @@ TextInputChannel::TextInputChannel( }); // Set input method callbacks. - input_method_context_->SetOnPreeditStart([this]() { - FT_LOG(Debug) << "onPreeditStart"; - active_model_->BeginComposing(); - }); + input_method_context_->SetOnPreeditStart([this]() { OnComposeBegin(); }); input_method_context_->SetOnPreeditChanged( [this](std::string str, int cursor_pos) -> void { - FT_LOG(Debug) << "onPreedit: str[" << str << "] cursor_pos[" - << cursor_pos << "]"; - if (str == "") { - // Enter pre-edit end stage. - return; - } - active_model_->UpdateComposingText(str); - SendStateUpdate(*active_model_); + OnComposeChanged(str, cursor_pos); }); - input_method_context_->SetOnPreeditEnd([this]() { - FT_LOG(Debug) << "onPreeditEnd"; + input_method_context_->SetOnPreeditEnd([this]() { OnComposeEnd(); }); - // Delete preedit-string, it will be committed. - int count = active_model_->composing_range().extent() - - active_model_->composing_range().base(); + input_method_context_->SetOnCommit( + [this](std::string str) -> void { OnCommit(str); }); - active_model_->CommitComposing(); - active_model_->EndComposing(); + input_method_context_->SetOnInputPanelStateChanged( + [this](int state) { OnInputPanelStateChanged(state); }); +} - active_model_->DeleteSurrounding(-count, count); +TextInputChannel::~TextInputChannel() {} - SendStateUpdate(*active_model_); - }); +void TextInputChannel::OnComposeBegin() { + FT_LOG(Error) << "onPreeditStart"; + active_model_->BeginComposing(); +} - input_method_context_->SetOnCommit([this](std::string str) -> void { - FT_LOG(Debug) << "OnCommit: str[" << str << "]"; - active_model_->AddText(str); - if (active_model_->composing()) { - active_model_->CommitComposing(); - active_model_->EndComposing(); - } - SendStateUpdate(*active_model_); - }); - - input_method_context_->SetOnInputPanelStateChanged([this](int state) { - if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) { - // Fallback for HW back-key. - input_method_context_->HideInputPanel(); - Reset(); - is_software_keyboard_showing_ = false; - } else { - is_software_keyboard_showing_ = true; - } - }); +void TextInputChannel::OnComposeChanged(std::string str, int cursor_pos) { + FT_LOG(Error) << "onPreedit: str[" << str << "] cursor_pos[" << cursor_pos + << "]"; + if (str == "") { + // Enter pre-edit end stage. + return; + } + active_model_->UpdateComposingText(str); + + SendStateUpdate(*active_model_); } -TextInputChannel::~TextInputChannel() {} +void TextInputChannel::OnComposeEnd() { + FT_LOG(Error) << "onPreeditEnd"; + // Delete preedit-string, it will be committed. + int count = active_model_->composing_range().extent() - + active_model_->composing_range().base(); + + active_model_->CommitComposing(); + active_model_->EndComposing(); + active_model_->DeleteSurrounding(-count, count); + + SendStateUpdate(*active_model_); +} + +void TextInputChannel::OnCommit(std::string str) { + FT_LOG(Error) << "OnCommit: str[" << str << "]"; + active_model_->AddText(str); + if (active_model_->composing()) { + active_model_->CommitComposing(); + active_model_->EndComposing(); + } + + SendStateUpdate(*active_model_); +} + +void TextInputChannel::OnInputPanelStateChanged(int state) { + if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) { + // Fallback for HW back-key. + input_method_context_->HideInputPanel(); + input_method_context_->ResetInputMethodContext(); + Reset(); + is_software_keyboard_showing_ = false; + } else { + is_software_keyboard_showing_ = true; + } +} bool TextInputChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { if (!active_model_) { diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 092ad3b08e5f5..6d59aac3baf8c 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -29,27 +29,61 @@ class TextInputChannel { bool IsSoftwareKeyboardShowing() { return is_software_keyboard_showing_; } + void OnComposeBegin(); + + void OnComposeChanged(std::string str, int cursor_pos); + + void OnComposeEnd(); + + void OnCommit(std::string str); + + void OnInputPanelStateChanged(int state); + bool SendKeyEvent(Ecore_Event_Key* key, bool is_down); private: + // Called when a method is called on |channel_|; void HandleMethodCall( const MethodCall& method_call, std::unique_ptr> result); + + // Sends the current state of the given model to the Flutter engine. void SendStateUpdate(const TextInputModel& model); + bool FilterEvent(Ecore_Event_Key* event, bool is_down); + void HandleUnfilteredEvent(Ecore_Event_Key* event); + + // Sends an action triggered by the Enter key to the Flutter engine. void EnterPressed(TextInputModel* model, bool select); + void Reset(); + bool ShouldNotFilterEvent(std::string key, bool is_ime); + // The MethodChannel used for communication with the Flutter engine. std::unique_ptr> channel_; + + // The active model. nullptr if not set. std::unique_ptr active_model_; + + // The Tizen input method context. nullptr if not set. std::unique_ptr input_method_context_; + // The active client id. int client_id_ = 0; + + // A flag indicating whether the software keyboard is being shown bool is_software_keyboard_showing_ = false; + + // An action requested by the user on the input client. See available options: + // https://api.flutter.dev/flutter/services/TextInputAction-class.html std::string input_action_; + + // Keyboard type of the client. See available options: + // https://api.flutter.dev/flutter/services/TextInputType-class.html std::string input_type_; + bool is_in_select_mode_ = false; }; From 0b020f9509905abc34e17cbd43e3b0ef61e7bb19 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Mon, 9 May 2022 15:16:14 +0900 Subject: [PATCH 02/12] Use the window ID instead of the window pointer * Remove the window dependency from TizenInputMethodContext Signed-off-by: Boram Bae --- shell/platform/tizen/flutter_tizen_view.cc | 2 +- shell/platform/tizen/tizen_input_method_context.cc | 12 ++++++------ shell/platform/tizen/tizen_input_method_context.h | 5 +---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index f1c029aa58cae..0ce355128968a 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -62,7 +62,7 @@ void FlutterTizenView::SetEngine(std::unique_ptr engine) { window_channel_ = std::make_unique(messenger, window_.get()); text_input_channel_ = std::make_unique( internal_plugin_registrar_->messenger(), - std::make_unique(window_.get())); + std::make_unique(window_->GetWindowId())); } void FlutterTizenView::CreateRenderSurface() { diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 4b83d1b53dbf6..b1b05e25d3276 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -5,7 +5,6 @@ #include "tizen_input_method_context.h" #include "flutter/shell/platform/tizen/logger.h" -#include "flutter/shell/platform/tizen/tizen_window.h" namespace { @@ -15,7 +14,9 @@ const char* GetEcoreImfContextAvailableId() { modules = ecore_imf_context_available_ids_get(); if (modules) { void* module; - EINA_LIST_FREE(modules, module) { return static_cast(module); } + EINA_LIST_FREE(modules, module) { + return static_cast(module); + } } return nullptr; } @@ -103,8 +104,7 @@ T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { namespace flutter { -TizenInputMethodContext::TizenInputMethodContext(TizenWindow* window) - : window_(window) { +TizenInputMethodContext::TizenInputMethodContext(uintptr_t window_id) { FT_ASSERT(window_); ecore_imf_init(); @@ -124,8 +124,8 @@ TizenInputMethodContext::TizenInputMethodContext(TizenWindow* window) return; } - ecore_imf_context_client_window_set( - imf_context_, reinterpret_cast(window_->GetWindowId())); + ecore_imf_context_client_window_set(imf_context_, + reinterpret_cast(window_id)); SetContextOptions(); SetInputPanelOptions(); RegisterEventCallbacks(); diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index dcc069c36791e..817abbddd76ed 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -21,15 +21,13 @@ using OnPreeditStart = std::function; using OnPreeditEnd = std::function; using OnInputPanelStateChanged = std::function; -class TizenWindow; - struct InputPanelGeometry { int32_t x = 0, y = 0, w = 0, h = 0; }; class TizenInputMethodContext { public: - TizenInputMethodContext(TizenWindow* window); + TizenInputMethodContext(uintptr_t window_id); ~TizenInputMethodContext(); bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); @@ -69,7 +67,6 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); - TizenWindow* window_ = nullptr; Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; OnPreeditChanged on_preedit_changed_; From 3ba9fbb8c3e8f408fbe904b469eda2aa3ba627ac Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Fri, 27 May 2022 11:36:21 +0900 Subject: [PATCH 03/12] Refactor the key event handling * Removes platform dependencies from all SendKeyEvent methods. * Adds methods related to composing a text to the FlutterView and TextInputChannel. * Transfers the key event filter role to TizenInputMethodContext. * Adds filter methods for each event type to TizenInputMethodContext. * Removes the concept of selection mode for text input. Signed-off-by: Boram Bae --- shell/platform/tizen/BUILD.gn | 3 + .../tizen/channels/key_event_channel.cc | 22 ++- .../tizen/channels/key_event_channel.h | 8 +- .../tizen/channels/platform_view_channel.cc | 11 +- .../tizen/channels/platform_view_channel.h | 9 +- .../tizen/channels/text_input_channel.cc | 172 +++++++----------- .../tizen/channels/text_input_channel.h | 40 ++-- shell/platform/tizen/external_texture.h | 1 - .../tizen/external_texture_pixel_gl.cc | 1 - .../tizen/external_texture_surface_gl.cc | 1 - shell/platform/tizen/flutter_tizen_view.cc | 46 ++++- shell/platform/tizen/flutter_tizen_view.h | 21 ++- .../tizen/public/flutter_platform_view.h | 14 +- .../tizen/tizen_input_method_context.cc | 78 +++++++- .../tizen/tizen_input_method_context.h | 12 +- shell/platform/tizen/tizen_renderer_egl.cc | 1 + shell/platform/tizen/tizen_renderer_egl.h | 1 - shell/platform/tizen/tizen_renderer_evas_gl.h | 1 - shell/platform/tizen/tizen_window.h | 11 +- .../platform/tizen/tizen_window_ecore_wl2.cc | 41 ++++- shell/platform/tizen/tizen_window_ecore_wl2.h | 2 + .../platform/tizen/tizen_window_elementary.cc | 109 ++++++++--- .../platform/tizen/tizen_window_elementary.h | 5 +- 23 files changed, 392 insertions(+), 218 deletions(-) diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 44574e346ac56..0100b97c15338 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -65,6 +65,8 @@ config("rootstrap_include_dirs") { "$custom_sysroot/usr/include/ecore-con-1", "$custom_sysroot/usr/include/ecore-evas-1", "$custom_sysroot/usr/include/ecore-file-1", + "$custom_sysroot/usr/include/ecore-imf-evas-1", + "$custom_sysroot/usr/include/ecore-input-evas-1", "$custom_sysroot/usr/include/edje-1", "$custom_sysroot/usr/include/eet-1", "$custom_sysroot/usr/include/efl-1/interfaces", @@ -150,6 +152,7 @@ template("embedder") { "dlog", "ecore", "ecore_imf", + "ecore_imf_evas", "ecore_input", "efl-extension", "eina", diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index 59c8a9a06ab63..499090048ee64 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -254,11 +254,15 @@ KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger) KeyEventChannel::~KeyEventChannel() {} -void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key, +void KeyEventChannel::SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, bool is_down, std::function callback) { - uint32_t scan_code = key->keycode; - auto iter1 = kSymbolToScanCode.find(key->key); + uint32_t scan_code = keycode; + auto iter1 = kSymbolToScanCode.find(key); if (iter1 != kSymbolToScanCode.end()) { scan_code = iter1->second; } @@ -269,16 +273,16 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key, key_code = iter2->second; } - int modifiers = 0; + int modifiers_key = 0; for (auto element : kEcoreModifierToGtkModifier) { - if (element.first & key->modifiers) { - modifiers |= element.second; + if (element.first & modifiers) { + modifiers_key |= element.second; } } uint32_t unicode_scalar_values = 0; - if (key->compose) { - unicode_scalar_values = Utf8ToUtf32CodePoint(key->compose); + if (compose) { + unicode_scalar_values = Utf8ToUtf32CodePoint(compose); } rapidjson::Document event(rapidjson::kObjectType); @@ -288,7 +292,7 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key, event.AddMember(kUnicodeScalarValuesKey, unicode_scalar_values, allocator); event.AddMember(kKeyCodeKey, key_code, allocator); event.AddMember(kScanCodeKey, scan_code, allocator); - event.AddMember(kModifiersKey, modifiers, allocator); + event.AddMember(kModifiersKey, modifiers_key, allocator); if (is_down) { event.AddMember(kTypeKey, kKeyDown, allocator); } else { diff --git a/shell/platform/tizen/channels/key_event_channel.h b/shell/platform/tizen/channels/key_event_channel.h index e70cbdfb707db..2df335c9ad9ef 100644 --- a/shell/platform/tizen/channels/key_event_channel.h +++ b/shell/platform/tizen/channels/key_event_channel.h @@ -5,8 +5,6 @@ #ifndef EMBEDDER_KEY_EVENT_CHANNEL_H_ #define EMBEDDER_KEY_EVENT_CHANNEL_H_ -#include - #include #include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h" @@ -20,7 +18,11 @@ class KeyEventChannel { explicit KeyEventChannel(BinaryMessenger* messenger); virtual ~KeyEventChannel(); - void SendKeyEvent(Ecore_Event_Key* event, + void SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, bool is_down, std::function callback); diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 2852760c56be6..097cc19eef27e 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -79,13 +79,18 @@ void PlatformViewChannel::ClearViewFactories() { view_factories_.clear(); } -void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* event, bool is_down) { +void PlatformViewChannel::SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) { PlatformView* view = FindFocusedView(); if (view) { if (is_down) { - view->DispatchKeyDownEvent(event); + view->DispatchKeyDownEvent(key, string, compose, modifiers, keycode); } else { - view->DispatchKeyUpEvent(event); + view->DispatchKeyUpEvent(key, string, compose, modifiers, keycode); } } } diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index 0ef3ef8b26fda..a7c2836dfc55a 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -5,8 +5,6 @@ #ifndef EMBEDDER_PLATFORM_VIEW_CHANNEL_H_ #define EMBEDDER_PLATFORM_VIEW_CHANNEL_H_ -#include - #include #include #include @@ -30,7 +28,12 @@ class PlatformViewChannel { return view_factories_; } - void SendKeyEvent(Ecore_Event_Key* event, bool is_down); + void SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down); private: PlatformView* FindViewById(int view_id); diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index e60c2743f2c50..4ca5050e26485 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -4,8 +4,6 @@ #include "text_input_channel.h" -#include - #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/logger.h" @@ -50,56 +48,45 @@ bool IsAsciiPrintableKey(char ch) { TextInputChannel::TextInputChannel( BinaryMessenger* messenger, - std::unique_ptr input_method_context) + TizenInputMethodContext* input_method_context) : channel_(std::make_unique>( messenger, kChannelName, &JsonMethodCodec::GetInstance())), - input_method_context_(std::move(input_method_context)) { + input_method_context_(input_method_context) { channel_->SetMethodCallHandler( [this](const MethodCall& call, std::unique_ptr> result) { HandleMethodCall(call, std::move(result)); }); - - // Set input method callbacks. - input_method_context_->SetOnPreeditStart([this]() { OnComposeBegin(); }); - - input_method_context_->SetOnPreeditChanged( - [this](std::string str, int cursor_pos) -> void { - OnComposeChanged(str, cursor_pos); - }); - - input_method_context_->SetOnPreeditEnd([this]() { OnComposeEnd(); }); - - input_method_context_->SetOnCommit( - [this](std::string str) -> void { OnCommit(str); }); - - input_method_context_->SetOnInputPanelStateChanged( - [this](int state) { OnInputPanelStateChanged(state); }); } TextInputChannel::~TextInputChannel() {} void TextInputChannel::OnComposeBegin() { - FT_LOG(Error) << "onPreeditStart"; + if (active_model_ == nullptr) { + return; + } active_model_->BeginComposing(); } -void TextInputChannel::OnComposeChanged(std::string str, int cursor_pos) { - FT_LOG(Error) << "onPreedit: str[" << str << "] cursor_pos[" << cursor_pos - << "]"; +void TextInputChannel::OnComposeChanged(const std::string& str, + int cursor_pos) { + if (active_model_ == nullptr) { + return; + } if (str == "") { // Enter pre-edit end stage. return; } active_model_->UpdateComposingText(str); - SendStateUpdate(*active_model_); } void TextInputChannel::OnComposeEnd() { - FT_LOG(Error) << "onPreeditEnd"; + if (active_model_ == nullptr) { + return; + } // Delete preedit-string, it will be committed. int count = active_model_->composing_range().extent() - active_model_->composing_range().base(); @@ -107,18 +94,18 @@ void TextInputChannel::OnComposeEnd() { active_model_->CommitComposing(); active_model_->EndComposing(); active_model_->DeleteSurrounding(-count, count); - SendStateUpdate(*active_model_); } -void TextInputChannel::OnCommit(std::string str) { - FT_LOG(Error) << "OnCommit: str[" << str << "]"; +void TextInputChannel::OnCommit(const std::string& str) { + if (active_model_ == nullptr) { + return; + } active_model_->AddText(str); if (active_model_->composing()) { active_model_->CommitComposing(); active_model_->EndComposing(); } - SendStateUpdate(*active_model_); } @@ -126,21 +113,24 @@ void TextInputChannel::OnInputPanelStateChanged(int state) { if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) { // Fallback for HW back-key. input_method_context_->HideInputPanel(); - input_method_context_->ResetInputMethodContext(); - Reset(); is_software_keyboard_showing_ = false; } else { is_software_keyboard_showing_ = true; } } -bool TextInputChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) { - if (!active_model_) { +bool TextInputChannel::SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) { + if (active_model_ == nullptr) { return false; } - if (!FilterEvent(key, is_down) && is_down) { - HandleUnfilteredEvent(key); + if (is_down) { + HandleUnfilteredEvent(key, string, modifiers); } return true; @@ -150,13 +140,12 @@ void TextInputChannel::HandleMethodCall( const MethodCall& method_call, std::unique_ptr> result) { const std::string& method = method_call.method_name(); - FT_LOG(Debug) << "method: " << method; if (method.compare(kShowMethod) == 0) { input_method_context_->ShowInputPanel(); } else if (method.compare(kHideMethod) == 0) { input_method_context_->HideInputPanel(); - Reset(); + input_method_context_->ResetInputMethodContext(); } else if (method.compare(kSetPlatformViewClient) == 0) { result->NotImplemented(); return; @@ -225,7 +214,7 @@ void TextInputChannel::HandleMethodCall( active_model_ = std::make_unique(); } else if (method.compare(kSetEditingStateMethod) == 0) { - Reset(); + input_method_context_->ResetInputMethodContext(); if (!method_call.arguments() || method_call.arguments()->IsNull()) { result->Error(kBadArgumentError, "Method invoked without args."); return; @@ -318,53 +307,17 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) { kTextKey, rapidjson::Value(model.GetText(), allocator).Move(), allocator); args->PushBack(editing_state, allocator); - FT_LOG(Debug) << "Send text:[" << model.GetText() << "]"; channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args)); } -bool TextInputChannel::FilterEvent(Ecore_Event_Key* event, bool is_down) { - bool handled = false; - -#ifdef WEARABLE_PROFILE - // Hardware keyboard is not supported on watch devices. - bool is_ime = true; - // FIXME: Only for wearable. - if (is_ime && strcmp(event->key, "Select") == 0) { - is_in_select_mode_ = true; - FT_LOG(Debug) << "Entering select mode."; - } -#else - const char* device_name = ecore_device_name_get(event->dev); - bool is_ime = device_name ? strcmp(device_name, "ime") == 0 : true; -#endif - - if (ShouldNotFilterEvent(event->key, is_ime)) { - FT_LOG(Info) << "Force redirect an IME key event: " << event->keyname; - Reset(); - return false; - } - - handled = - input_method_context_->FilterEvent(event, is_ime ? "ime" : "", is_down); - -#ifdef WEARABLE_PROFILE - if (!handled && !strcmp(event->key, "Return") && is_in_select_mode_) { - is_in_select_mode_ = false; - handled = true; - FT_LOG(Debug) << "Leaving select mode."; - } -#endif - - return handled; -} - -void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) { - bool select = !strcmp(event->key, "Select"); - bool shift = event->modifiers & ECORE_SHIFT; +void TextInputChannel::HandleUnfilteredEvent(const char* key, + const char* string, + uint32_t modifires) { + bool shift = modifires & ECORE_SHIFT; bool needs_update = false; - std::string key = event->key; + std::string key_str = key; - if (key == "Left") { + if (key_str == "Left") { if (shift) { TextRange selection = active_model_->selection(); needs_update = active_model_->SetSelection( @@ -372,7 +325,7 @@ void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) { } else { needs_update = active_model_->MoveCursorBack(); } - } else if (key == "Right") { + } else if (key_str == "Right") { if (shift) { TextRange selection = active_model_->selection(); needs_update = active_model_->SetSelection( @@ -380,30 +333,36 @@ void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) { } else { needs_update = active_model_->MoveCursorForward(); } - } else if (key == "End") { + } else if (key_str == "End") { if (shift) { needs_update = active_model_->SelectToEnd(); } else { needs_update = active_model_->MoveCursorToEnd(); } - } else if (key == "Home") { + } else if (key_str == "Home") { if (shift) { needs_update = active_model_->SelectToBeginning(); } else { needs_update = active_model_->MoveCursorToBeginning(); } - } else if (key == "BackSpace") { + } else if (key_str == "BackSpace") { needs_update = active_model_->Backspace(); - } else if (key == "Delete") { + } else if (key_str == "Delete") { needs_update = active_model_->Delete(); - } else if (event->string && strlen(event->string) == 1 && - IsAsciiPrintableKey(event->string[0])) { - active_model_->AddCodePoint(event->string[0]); + } else if (string && strlen(string) == 1 && IsAsciiPrintableKey(string[0])) { + active_model_->AddCodePoint(string[0]); needs_update = true; - } else if (key == "Return" || (select && !is_in_select_mode_)) { - EnterPressed(active_model_.get(), select); + } else if (key_str == "Return") { + EnterPressed(active_model_.get()); return; - } else { + } +#ifdef TV_PROFILE + else if (key_str == "Select") { + SelectPressed(active_model_.get()); + return; + } +#endif + else { FT_LOG(Warn) << "Key[" << key << "] is unhandled."; } @@ -412,8 +371,8 @@ void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) { } } -void TextInputChannel::EnterPressed(TextInputModel* model, bool select) { - if (!select && input_type_ == kMultilineInputType) { +void TextInputChannel::EnterPressed(TextInputModel* model) { + if (input_type_ == kMultilineInputType) { model->AddCodePoint('\n'); SendStateUpdate(*model); } @@ -425,24 +384,15 @@ void TextInputChannel::EnterPressed(TextInputModel* model, bool select) { channel_->InvokeMethod(kPerformActionMethod, std::move(args)); } -void TextInputChannel::Reset() { - is_in_select_mode_ = false; - input_method_context_->ResetInputMethodContext(); -} +#ifdef TV_PROFILE +void TextInputChannel::SelectPressed(TextInputModel* model) { + auto args = std::make_unique(rapidjson::kArrayType); + rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator(); + args->PushBack(client_id_, allocator); + args->PushBack(rapidjson::Value(input_action_, allocator).Move(), allocator); -bool TextInputChannel::ShouldNotFilterEvent(std::string key, bool is_ime) { - // Force redirect to HandleUnfilteredEvent(especially on TV) - // If you don't do this, it will affects the input panel. - // For example, when the left key of the input panel is pressed, the focus - // of the input panel is shifted to left! - // What we want is to move only the cursor on the text editor. - if (is_ime && !is_in_select_mode_ && - (key == "Left" || key == "Right" || key == "Up" || key == "Down" || - key == "End" || key == "Home" || key == "BackSpace" || key == "Delete" || - key == "Select")) { - return true; - } - return false; + channel_->InvokeMethod(kPerformActionMethod, std::move(args)); } +#endif } // namespace flutter diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 6d59aac3baf8c..fa504a34c4176 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -5,10 +5,6 @@ #ifndef EMBEDDER_TEXT_INPUT_CHANNEL_H_ #define EMBEDDER_TEXT_INPUT_CHANNEL_H_ -#define EFL_BETA_API_SUPPORT -#include -#include - #include #include @@ -22,24 +18,28 @@ namespace flutter { class TextInputChannel { public: - explicit TextInputChannel( - BinaryMessenger* messenger, - std::unique_ptr input_method_context); + explicit TextInputChannel(BinaryMessenger* messenger, + TizenInputMethodContext* input_method_context); virtual ~TextInputChannel(); bool IsSoftwareKeyboardShowing() { return is_software_keyboard_showing_; } void OnComposeBegin(); - void OnComposeChanged(std::string str, int cursor_pos); + void OnComposeChanged(const std::string& str, int cursor_pos); void OnComposeEnd(); - void OnCommit(std::string str); + void OnCommit(const std::string& str); void OnInputPanelStateChanged(int state); - bool SendKeyEvent(Ecore_Event_Key* key, bool is_down); + bool SendKeyEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down); private: // Called when a method is called on |channel_|; @@ -50,17 +50,17 @@ class TextInputChannel { // Sends the current state of the given model to the Flutter engine. void SendStateUpdate(const TextInputModel& model); - bool FilterEvent(Ecore_Event_Key* event, bool is_down); - - void HandleUnfilteredEvent(Ecore_Event_Key* event); + void HandleUnfilteredEvent(const char* key, + const char* string, + uint32_t modifires); // Sends an action triggered by the Enter key to the Flutter engine. - void EnterPressed(TextInputModel* model, bool select); - - void Reset(); - - bool ShouldNotFilterEvent(std::string key, bool is_ime); + void EnterPressed(TextInputModel* model); +#ifdef TV_PROFILE + // Sends an action triggered by the Select key to the Flutter engine. + void SelectPressed(TextInputModel* model); +#endif // The MethodChannel used for communication with the Flutter engine. std::unique_ptr> channel_; @@ -68,7 +68,7 @@ class TextInputChannel { std::unique_ptr active_model_; // The Tizen input method context. nullptr if not set. - std::unique_ptr input_method_context_; + TizenInputMethodContext* input_method_context_ = nullptr; // The active client id. int client_id_ = 0; @@ -83,8 +83,6 @@ class TextInputChannel { // Keyboard type of the client. See available options: // https://api.flutter.dev/flutter/services/TextInputType-class.html std::string input_type_; - - bool is_in_select_mode_ = false; }; } // namespace flutter diff --git a/shell/platform/tizen/external_texture.h b/shell/platform/tizen/external_texture.h index 4d3f6e913d030..53c77acaa8074 100644 --- a/shell/platform/tizen/external_texture.h +++ b/shell/platform/tizen/external_texture.h @@ -12,7 +12,6 @@ #include "flutter/shell/platform/embedder/embedder.h" #ifdef TIZEN_RENDERER_EVAS_GL -#undef EFL_BETA_API_SUPPORT #include #else #include diff --git a/shell/platform/tizen/external_texture_pixel_gl.cc b/shell/platform/tizen/external_texture_pixel_gl.cc index 85573ea396204..340ccc8773fb7 100644 --- a/shell/platform/tizen/external_texture_pixel_gl.cc +++ b/shell/platform/tizen/external_texture_pixel_gl.cc @@ -5,7 +5,6 @@ #include "external_texture_pixel_gl.h" #ifdef TIZEN_RENDERER_EVAS_GL -#undef EFL_BETA_API_SUPPORT #include "tizen_evas_gl_helper.h" extern Evas_GL* g_evas_gl; EVAS_GL_GLOBAL_GLES2_DECLARE(); diff --git a/shell/platform/tizen/external_texture_surface_gl.cc b/shell/platform/tizen/external_texture_surface_gl.cc index dcbc0d9001704..99b6552269eba 100644 --- a/shell/platform/tizen/external_texture_surface_gl.cc +++ b/shell/platform/tizen/external_texture_surface_gl.cc @@ -7,7 +7,6 @@ #include #ifdef TIZEN_RENDERER_EVAS_GL -#undef EFL_BETA_API_SUPPORT #include "tizen_evas_gl_helper.h" extern Evas_GL* g_evas_gl; EVAS_GL_GLOBAL_GLES2_DECLARE(); diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 0ce355128968a..d81d4323c2fe1 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -61,8 +61,7 @@ void FlutterTizenView::SetEngine(std::unique_ptr engine) { std::make_unique(messenger, window_.get()); window_channel_ = std::make_unique(messenger, window_.get()); text_input_channel_ = std::make_unique( - internal_plugin_registrar_->messenger(), - std::make_unique(window_->GetWindowId())); + internal_plugin_registrar_->messenger(), window_->input_method_context()); } void FlutterTizenView::CreateRenderSurface() { @@ -194,27 +193,33 @@ void FlutterTizenView::OnScroll(double x, delta_y * scroll_offset_multiplier, timestamp, device_kind, device_id); } -void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { +void FlutterTizenView::OnKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) { if (is_down) { - FT_LOG(Info) << "Key symbol: " << event->key << ", code: 0x" << std::setw(8) - << std::setfill('0') << std::right << std::hex - << event->keycode; + FT_LOG(Info) << "Key symbol: " << key << ", code: 0x" << std::setw(8) + << std::setfill('0') << std::right << std::hex << keycode; } if (text_input_channel_) { - if (text_input_channel_->SendKeyEvent(event, is_down)) { + if (text_input_channel_->SendKeyEvent(key, string, compose, modifiers, + keycode, is_down)) { return; } } if (engine_->platform_view_channel()) { - engine_->platform_view_channel()->SendKeyEvent(event, is_down); + engine_->platform_view_channel()->SendKeyEvent(key, string, compose, + modifiers, keycode, is_down); } if (engine_->key_event_channel()) { engine_->key_event_channel()->SendKeyEvent( - event, is_down, - [engine = engine_.get(), symbol = std::string(event->key), + key, string, compose, modifiers, keycode, is_down, + [engine = engine_.get(), symbol = std::string(key), is_down](bool handled) { if (handled) { return; @@ -230,6 +235,27 @@ void FlutterTizenView::OnKey(Ecore_Event_Key* event, bool is_down) { } } +void FlutterTizenView::OnComposeBegin() { + text_input_channel_->OnComposeBegin(); +} + +void FlutterTizenView::OnComposeChanged(const std::string& str, + int cursor_pos) { + text_input_channel_->OnComposeChanged(str, cursor_pos); +} + +void FlutterTizenView::OnComposeEnd() { + text_input_channel_->OnComposeEnd(); +} + +void FlutterTizenView::OnCommit(const std::string& str) { + text_input_channel_->OnCommit(str); +} + +void FlutterTizenView::OnInputPanelStateChanged(int state) { + text_input_channel_->OnInputPanelStateChanged(state); +} + void FlutterTizenView::SendInitialGeometry() { OnRotate(window_->GetRotation()); } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index b59fa6d7d0606..3806def60c172 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -8,8 +8,6 @@ #include -#include - #include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h" #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/tizen/channels/platform_channel.h" @@ -83,7 +81,22 @@ class FlutterTizenView { FlutterPointerDeviceKind device_kind, int32_t device_id); - void OnKey(Ecore_Event_Key* event, bool is_down); + void OnKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down); + + void OnComposeBegin(); + + void OnComposeChanged(const std::string& str, int cursor_pos); + + void OnComposeEnd(); + + void OnCommit(const std::string& str); + + void OnInputPanelStateChanged(int state); FlutterTransformation GetFlutterTransformation() { return flutter_transformation_; @@ -91,6 +104,8 @@ class FlutterTizenView { void SendInitialGeometry(); + TextInputChannel* text_input_channel() { return text_input_channel_.get(); } + private: // Sends a window metrics update to the Flutter engine using current window // dimensions in physical. diff --git a/shell/platform/tizen/public/flutter_platform_view.h b/shell/platform/tizen/public/flutter_platform_view.h index c0b18949976f5..a87b9c197d979 100644 --- a/shell/platform/tizen/public/flutter_platform_view.h +++ b/shell/platform/tizen/public/flutter_platform_view.h @@ -5,7 +5,6 @@ #ifndef FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_ #define FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_ -#include #include #include #include @@ -46,8 +45,17 @@ class PlatformView { bool IsFocused() { return is_focused_; } - virtual void DispatchKeyDownEvent(Ecore_Event_Key* event) = 0; - virtual void DispatchKeyUpEvent(Ecore_Event_Key* event) = 0; + virtual void DispatchKeyDownEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode) = 0; + + virtual void DispatchKeyUpEvent(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode) = 0; private: flutter::PluginRegistrar* registrar_; diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index b1b05e25d3276..51d9b0ab00e22 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -14,9 +14,7 @@ const char* GetEcoreImfContextAvailableId() { modules = ecore_imf_context_available_ids_get(); if (modules) { void* module; - EINA_LIST_FREE(modules, module) { - return static_cast(module); - } + EINA_LIST_FREE(modules, module) { return static_cast(module); } } return nullptr; } @@ -141,28 +139,62 @@ TizenInputMethodContext::~TizenInputMethodContext() { ecore_imf_shutdown(); } -bool TizenInputMethodContext::FilterEvent(Ecore_Event_Key* event, - const char* dev_name, - bool is_down) { +bool TizenInputMethodContext::FilterEcoreEventKey(Ecore_Event_Key* event, + bool is_down) { FT_ASSERT(imf_context_); FT_ASSERT(event); - FT_ASSERT(dev_name); + + const char* device_name = ecore_device_name_get(event->dev); + bool is_ime = device_name ? strcmp(device_name, "ime") == 0 : true; + + if (ShouldNotFilterEvent(event->key, is_ime)) { + return false; + } if (is_down) { Ecore_IMF_Event_Key_Down imf_event = - EcoreEventKeyToEcoreImfEvent(event, dev_name); + EcoreEventKeyToEcoreImfEvent(event, + device_name); return ecore_imf_context_filter_event( imf_context_, ECORE_IMF_EVENT_KEY_DOWN, reinterpret_cast(&imf_event)); } else { Ecore_IMF_Event_Key_Up imf_event = - EcoreEventKeyToEcoreImfEvent(event, dev_name); + EcoreEventKeyToEcoreImfEvent(event, + device_name); return ecore_imf_context_filter_event( imf_context_, ECORE_IMF_EVENT_KEY_UP, reinterpret_cast(&imf_event)); } } +bool TizenInputMethodContext::FilterEvasEventKeyDown( + Evas_Event_Key_Down* event) { + if (ShouldNotFilterEvent(event->key, true)) { + return false; + } + + Ecore_IMF_Event_Key_Down imf_event; + ecore_imf_evas_event_key_down_wrap(event, &imf_event); + + return ecore_imf_context_filter_event( + imf_context_, ECORE_IMF_EVENT_KEY_DOWN, + reinterpret_cast(&imf_event)); +} + +bool TizenInputMethodContext::FilterEvasEventKeyUp(Evas_Event_Key_Up* event) { + if (ShouldNotFilterEvent(event->key, true)) { + return false; + } + + Ecore_IMF_Event_Key_Up imf_event; + ecore_imf_evas_event_key_up_wrap(event, &imf_event); + + return ecore_imf_context_filter_event( + imf_context_, ECORE_IMF_EVENT_KEY_UP, + reinterpret_cast(&imf_event)); +} + InputPanelGeometry TizenInputMethodContext::GetInputPanelGeometry() { FT_ASSERT(imf_context_); InputPanelGeometry geometry; @@ -188,6 +220,12 @@ void TizenInputMethodContext::HideInputPanel() { ecore_imf_context_input_panel_hide(imf_context_); } +bool TizenInputMethodContext::IsInputPanelShown() { + Ecore_IMF_Input_Panel_State state = + ecore_imf_context_input_panel_state_get(imf_context_); + return state == ECORE_IMF_INPUT_PANEL_STATE_SHOW; +} + void TizenInputMethodContext::SetInputPanelLayout( const std::string& input_type) { FT_ASSERT(imf_context_); @@ -316,4 +354,26 @@ void TizenInputMethodContext::SetInputPanelOptions() { imf_context_, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC); } +bool TizenInputMethodContext::ShouldNotFilterEvent(std::string key, + bool is_ime) { + // Force redirect to HandleUnfilteredEvent(especially on TV) + // If you don't do this, it will affects the input panel. + // For example, when the left key of the input panel is pressed, the focus + // of the input panel is shifted to left! + // What we want is to move only the cursor on the text editor. + + if (is_ime && (key == "Left" || key == "Right" || key == "Up" || + key == "Down" || key == "End" || key == "Home" || + key == "BackSpace" || key == "Delete")) { + return true; + } +#ifdef TV_PROFILE + if (is_ime && key == "Select") { + return true; + } +#endif + + return false; +} + } // namespace flutter diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 817abbddd76ed..63e7b93e0a51b 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -5,8 +5,8 @@ #ifndef EMBEDDER_TIZEN_INPUT_METHOD_CONTEXT_H_ #define EMBEDDER_TIZEN_INPUT_METHOD_CONTEXT_H_ -#define EFL_BETA_API_SUPPORT #include +#include #include #include @@ -30,7 +30,11 @@ class TizenInputMethodContext { TizenInputMethodContext(uintptr_t window_id); ~TizenInputMethodContext(); - bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down); + bool FilterEcoreEventKey(Ecore_Event_Key* event, bool is_down); + + bool FilterEvasEventKeyDown(Evas_Event_Key_Down* event); + + bool FilterEvasEventKeyUp(Evas_Event_Key_Up* event); InputPanelGeometry GetInputPanelGeometry(); @@ -40,6 +44,8 @@ class TizenInputMethodContext { void HideInputPanel(); + bool IsInputPanelShown(); + void SetInputPanelLayout(const std::string& layout); void SetInputPanelLayoutVariation(bool is_signed, bool is_decimal); @@ -67,6 +73,8 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); + bool ShouldNotFilterEvent(std::string key, bool is_ime); + Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; OnPreeditChanged on_preedit_changed_; diff --git a/shell/platform/tizen/tizen_renderer_egl.cc b/shell/platform/tizen/tizen_renderer_egl.cc index 0b88fc2212235..327797e0d23fd 100644 --- a/shell/platform/tizen/tizen_renderer_egl.cc +++ b/shell/platform/tizen/tizen_renderer_egl.cc @@ -4,6 +4,7 @@ #include "tizen_renderer_egl.h" +#define EFL_BETA_API_SUPPORT #include #include #include diff --git a/shell/platform/tizen/tizen_renderer_egl.h b/shell/platform/tizen/tizen_renderer_egl.h index 74708e3b65fc6..a981ae1a76cd4 100644 --- a/shell/platform/tizen/tizen_renderer_egl.h +++ b/shell/platform/tizen/tizen_renderer_egl.h @@ -5,7 +5,6 @@ #ifndef EMBEDDER_TIZEN_RENDERER_EGL_H_ #define EMBEDDER_TIZEN_RENDERER_EGL_H_ -#define EFL_BETA_API_SUPPORT #include #include diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.h b/shell/platform/tizen/tizen_renderer_evas_gl.h index badba04499004..fd41d8a5c8097 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.h +++ b/shell/platform/tizen/tizen_renderer_evas_gl.h @@ -7,7 +7,6 @@ #include -#undef EFL_BETA_API_SUPPORT #include #include diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index b4a6ed94d5d2b..a058e2684b71c 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -10,6 +10,8 @@ #include #include +#include "flutter/shell/platform/tizen/tizen_input_method_context.h" + namespace flutter { class FlutterTizenView; @@ -20,8 +22,6 @@ class TizenWindow { int32_t left = 0, top = 0, width = 0, height = 0; }; - TizenWindow(); - virtual ~TizenWindow() = default; // Sets the delegate used to communicate state changes from window to view @@ -65,6 +65,10 @@ class TizenWindow { // This is a temporary implementation that is only used by the window channel. virtual void OnGeometryChanged(Geometry geometry) = 0; + TizenInputMethodContext* input_method_context() { + return input_method_context_.get(); + } + protected: explicit TizenWindow(Geometry geometry, bool transparent, @@ -81,6 +85,9 @@ class TizenWindow { bool top_level_ = false; FlutterTizenView* view_ = nullptr; + + // The Tizen input method context. nullptr if not set. + std::unique_ptr input_method_context_; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 4353f4d30c256..e77c908529474 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -30,6 +30,7 @@ TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, SetWindowOptions(); RegisterEventHandlers(); + PrepareInputMethod(); Show(); } @@ -243,7 +244,16 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->view_->OnKey(key_event, true); + int handled = false; + if (self->input_method_context_->IsInputPanelShown()) { + handled = self->input_method_context_->FilterEcoreEventKey( + key_event, true); + } + if (!handled) { + self->view_->OnKey(key_event->key, key_event->string, + key_event->compose, key_event->modifiers, + key_event->keycode, true); + } return ECORE_CALLBACK_DONE; } } @@ -258,7 +268,16 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (self->view_) { auto* key_event = reinterpret_cast(event); if (key_event->window == self->GetWindowId()) { - self->view_->OnKey(key_event, false); + int handled = false; + if (self->input_method_context_->IsInputPanelShown()) { + handled = self->input_method_context_->FilterEcoreEventKey( + key_event, false); + } + if (!handled) { + self->view_->OnKey(key_event->key, key_event->string, + key_event->compose, key_event->modifiers, + key_event->keycode, false); + } return ECORE_CALLBACK_DONE; } } @@ -393,4 +412,22 @@ void TizenWindowEcoreWl2::SetTizenPolicyNotificationLevel(int level) { tizen_policy_, ecore_wl2_window_surface_get(ecore_wl2_window_), level); } +void TizenWindowEcoreWl2::PrepareInputMethod() { + input_method_context_ = + std::make_unique(GetWindowId()); + + // Set input method callbacks. + input_method_context_->SetOnPreeditStart( + [this]() { view_->OnComposeBegin(); }); + input_method_context_->SetOnPreeditChanged( + [this](std::string str, int cursor_pos) { + view_->OnComposeChanged(str, cursor_pos); + }); + input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); + input_method_context_->SetOnCommit( + [this](std::string str) { view_->OnCommit(str); }); + input_method_context_->SetOnInputPanelStateChanged( + [this](int state) { view_->OnInputPanelStateChanged(state); }); +} + } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index 25dc1f56f9287..026c949e63cfc 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -65,6 +65,8 @@ class TizenWindowEcoreWl2 : public TizenWindow { void SetTizenPolicyNotificationLevel(int level); + void PrepareInputMethod(); + Ecore_Wl2_Display* ecore_wl2_display_ = nullptr; Ecore_Wl2_Window* ecore_wl2_window_ = nullptr; diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index 49725fe0d6fc9..7eca84259111f 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -17,6 +17,20 @@ static const int kScrollDirectionVertical = 0; static const int kScrollDirectionHorizontal = 1; static const int kScrollOffsetMultiplier = 20; +uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) { + uint32_t modifiers = 0; + if (evas_key_modifier_is_set(evas_modifier, "Contorol")) { + modifiers |= ECORE_EVENT_MODIFIER_CTRL; + } + if (evas_key_modifier_is_set(evas_modifier, "Alt")) { + modifiers |= ECORE_EVENT_MODIFIER_ALT; + } + if (evas_key_modifier_is_set(evas_modifier, "Shift")) { + modifiers |= ECORE_EVENT_MODIFIER_SHIFT; + } + return modifiers; +} + } // namespace namespace flutter { @@ -33,6 +47,7 @@ TizenWindowElementary::TizenWindowElementary(Geometry geometry, SetWindowOptions(); RegisterEventHandlers(); + PrepareInputMethod(); Show(); } @@ -217,36 +232,54 @@ void TizenWindowElementary::RegisterEventHandlers() { elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL], this); - // FIXME: ues EVAS_CALLBACK_KEY_DOWN, EVAS_CALLBACK_KEY_UP - ecore_event_key_handlers_.push_back(ecore_event_handler_add( - ECORE_EVENT_KEY_DOWN, - [](void* data, int type, void* event) -> Eina_Bool { - auto* self = reinterpret_cast(data); - if (self->view_) { - auto* key_event = reinterpret_cast(event); - if (key_event->window == self->GetWindowId()) { - self->view_->OnKey(key_event, false); - return ECORE_CALLBACK_DONE; - } + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->elm_win_ == object) { + auto* key_event = reinterpret_cast(event_info); + int handled = false; + if (self->input_method_context()->IsInputPanelShown()) { + handled = + self->input_method_context_->FilterEvasEventKeyDown(key_event); + } + if (!handled) { + self->view_->OnKey( + key_event->key, key_event->string, key_event->compose, + EvasModifierToEcoreEventModifiers(key_event->modifiers), + key_event->keycode, true); } - return ECORE_CALLBACK_PASS_ON; - }, - this)); + } + } + }; + evas_object_event_callback_add(elm_win_, EVAS_CALLBACK_KEY_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN], + this); - ecore_event_key_handlers_.push_back(ecore_event_handler_add( - ECORE_EVENT_KEY_UP, - [](void* data, int type, void* event) -> Eina_Bool { + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); if (self->view_) { - auto* key_event = reinterpret_cast(event); - if (key_event->window == self->GetWindowId()) { - self->view_->OnKey(key_event, true); - return ECORE_CALLBACK_DONE; + if (self->elm_win_ == object) { + auto* key_event = reinterpret_cast(event_info); + int handled = false; + if (self->input_method_context_->IsInputPanelShown()) { + handled = + self->input_method_context_->FilterEvasEventKeyUp(key_event); + } + if (!handled) { + self->view_->OnKey( + key_event->key, key_event->string, key_event->compose, + EvasModifierToEcoreEventModifiers(key_event->modifiers), + key_event->keycode, false); + } } } - return ECORE_CALLBACK_PASS_ON; - }, - this)); + }; + evas_object_event_callback_add(elm_win_, EVAS_CALLBACK_KEY_UP, + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP], + this); } void TizenWindowElementary::UnregisterEventHandlers() { @@ -265,11 +298,11 @@ void TizenWindowElementary::UnregisterEventHandlers() { evas_object_event_callback_del( elm_win_, EVAS_CALLBACK_MOUSE_WHEEL, evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL]); - - for (Ecore_Event_Handler* handler : ecore_event_key_handlers_) { - ecore_event_handler_del(handler); - } - ecore_event_key_handlers_.clear(); + evas_object_event_callback_del( + elm_win_, EVAS_CALLBACK_KEY_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN]); + evas_object_event_callback_del(elm_win_, EVAS_CALLBACK_KEY_UP, + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]); } TizenWindow::Geometry TizenWindowElementary::GetWindowGeometry() { @@ -345,4 +378,22 @@ void TizenWindowElementary::OnGeometryChanged(Geometry geometry) { view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); } +void TizenWindowElementary::PrepareInputMethod() { + input_method_context_ = + std::make_unique(GetWindowId()); + + // Set input method callbacks. + input_method_context_->SetOnPreeditStart( + [this]() { view_->OnComposeBegin(); }); + input_method_context_->SetOnPreeditChanged( + [this](std::string str, int cursor_pos) { + view_->OnComposeChanged(str, cursor_pos); + }); + input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); + input_method_context_->SetOnCommit( + [this](std::string str) { view_->OnCommit(str); }); + input_method_context_->SetOnInputPanelStateChanged( + [this](int state) { view_->OnInputPanelStateChanged(state); }); +} + } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 930cdc5c2f0ec..97f358ff24c98 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -8,8 +8,6 @@ #include "flutter/shell/platform/tizen/tizen_window.h" -#define EFL_BETA_API_SUPPORT -#include #include #include @@ -65,13 +63,14 @@ class TizenWindowElementary : public TizenWindow { void UnregisterEventHandlers(); + void PrepareInputMethod(); + Evas_Object* elm_win_ = nullptr; Evas_Object* image_ = nullptr; Evas_Smart_Cb rotatoin_changed_callback_; std::unordered_map evas_object_callbacks_; - std::vector ecore_event_key_handlers_; }; } // namespace flutter From 25158001700e82e426b19e41b34281f8e14caf13 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 31 May 2022 11:12:12 +0900 Subject: [PATCH 04/12] Update based on review Signed-off-by: Boram Bae --- .../tizen/channels/text_input_channel.cc | 32 +++++++++---------- .../tizen/channels/text_input_channel.h | 11 ++++--- shell/platform/tizen/flutter_tizen_view.cc | 5 ++- shell/platform/tizen/flutter_tizen_view.h | 2 +- .../tizen/tizen_input_method_context.cc | 23 +++++++------ .../tizen/tizen_input_method_context.h | 2 +- .../platform/tizen/tizen_window_ecore_wl2.cc | 2 +- .../platform/tizen/tizen_window_elementary.cc | 12 +++---- .../platform/tizen/tizen_window_elementary.h | 2 +- 9 files changed, 45 insertions(+), 46 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 4ca5050e26485..b86fa81642541 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -70,8 +70,7 @@ void TextInputChannel::OnComposeBegin() { active_model_->BeginComposing(); } -void TextInputChannel::OnComposeChanged(const std::string& str, - int cursor_pos) { +void TextInputChannel::OnComposeChange(const std::string& str, int cursor_pos) { if (active_model_ == nullptr) { return; } @@ -80,7 +79,7 @@ void TextInputChannel::OnComposeChanged(const std::string& str, return; } active_model_->UpdateComposingText(str); - SendStateUpdate(*active_model_); + SendStateUpdate(); } void TextInputChannel::OnComposeEnd() { @@ -94,7 +93,7 @@ void TextInputChannel::OnComposeEnd() { active_model_->CommitComposing(); active_model_->EndComposing(); active_model_->DeleteSurrounding(-count, count); - SendStateUpdate(*active_model_); + SendStateUpdate(); } void TextInputChannel::OnCommit(const std::string& str) { @@ -106,7 +105,7 @@ void TextInputChannel::OnCommit(const std::string& str) { active_model_->CommitComposing(); active_model_->EndComposing(); } - SendStateUpdate(*active_model_); + SendStateUpdate(); } void TextInputChannel::OnInputPanelStateChanged(int state) { @@ -273,7 +272,7 @@ void TextInputChannel::HandleMethodCall( static_cast(composing_extent_value)), cursor_offset); } - SendStateUpdate(*active_model_); + SendStateUpdate(); } else { result->NotImplemented(); return; @@ -283,12 +282,12 @@ void TextInputChannel::HandleMethodCall( result->Success(); } -void TextInputChannel::SendStateUpdate(const TextInputModel& model) { +void TextInputChannel::SendStateUpdate() { auto args = std::make_unique(rapidjson::kArrayType); rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator(); args->PushBack(client_id_, allocator); - TextRange selection = model.selection(); + TextRange selection = active_model_->selection(); rapidjson::Value editing_state(rapidjson::kObjectType); int composing_base = active_model_->composing() ? active_model_->composing_range().base() : -1; @@ -304,7 +303,8 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) { editing_state.AddMember(kSelectionExtentKey, selection.extent(), allocator); editing_state.AddMember(kSelectionIsDirectionalKey, false, allocator); editing_state.AddMember( - kTextKey, rapidjson::Value(model.GetText(), allocator).Move(), allocator); + kTextKey, rapidjson::Value(active_model_->GetText(), allocator).Move(), + allocator); args->PushBack(editing_state, allocator); channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args)); @@ -353,12 +353,12 @@ void TextInputChannel::HandleUnfilteredEvent(const char* key, active_model_->AddCodePoint(string[0]); needs_update = true; } else if (key_str == "Return") { - EnterPressed(active_model_.get()); + EnterPressed(); return; } #ifdef TV_PROFILE else if (key_str == "Select") { - SelectPressed(active_model_.get()); + SelectPressed(); return; } #endif @@ -367,14 +367,14 @@ void TextInputChannel::HandleUnfilteredEvent(const char* key, } if (needs_update) { - SendStateUpdate(*active_model_); + SendStateUpdate(); } } -void TextInputChannel::EnterPressed(TextInputModel* model) { +void TextInputChannel::EnterPressed() { if (input_type_ == kMultilineInputType) { - model->AddCodePoint('\n'); - SendStateUpdate(*model); + active_model_->AddCodePoint('\n'); + SendStateUpdate(); } auto args = std::make_unique(rapidjson::kArrayType); rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator(); @@ -385,7 +385,7 @@ void TextInputChannel::EnterPressed(TextInputModel* model) { } #ifdef TV_PROFILE -void TextInputChannel::SelectPressed(TextInputModel* model) { +void TextInputChannel::SelectPressed() { auto args = std::make_unique(rapidjson::kArrayType); rapidjson::MemoryPoolAllocator<>& allocator = args->GetAllocator(); args->PushBack(client_id_, allocator); diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index fa504a34c4176..d4373fb4c6886 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -26,7 +26,7 @@ class TextInputChannel { void OnComposeBegin(); - void OnComposeChanged(const std::string& str, int cursor_pos); + void OnComposeChange(const std::string& str, int cursor_pos); void OnComposeEnd(); @@ -47,20 +47,21 @@ class TextInputChannel { const MethodCall& method_call, std::unique_ptr> result); - // Sends the current state of the given model to the Flutter engine. - void SendStateUpdate(const TextInputModel& model); + // Sends the current state of |active_model_| to the Flutter engine. + void SendStateUpdate(); void HandleUnfilteredEvent(const char* key, const char* string, uint32_t modifires); // Sends an action triggered by the Enter key to the Flutter engine. - void EnterPressed(TextInputModel* model); + void EnterPressed(); #ifdef TV_PROFILE // Sends an action triggered by the Select key to the Flutter engine. - void SelectPressed(TextInputModel* model); + void SelectPressed(); #endif + // The MethodChannel used for communication with the Flutter engine. std::unique_ptr> channel_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index d81d4323c2fe1..5e4b124e59a87 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -239,9 +239,8 @@ void FlutterTizenView::OnComposeBegin() { text_input_channel_->OnComposeBegin(); } -void FlutterTizenView::OnComposeChanged(const std::string& str, - int cursor_pos) { - text_input_channel_->OnComposeChanged(str, cursor_pos); +void FlutterTizenView::OnComposeChange(const std::string& str, int cursor_pos) { + text_input_channel_->OnComposeChange(str, cursor_pos); } void FlutterTizenView::OnComposeEnd() { diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index 3806def60c172..f039f04d48f48 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -90,7 +90,7 @@ class FlutterTizenView { void OnComposeBegin(); - void OnComposeChanged(const std::string& str, int cursor_pos); + void OnComposeChange(const std::string& str, int cursor_pos); void OnComposeEnd(); diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 51d9b0ab00e22..9e121d04a41ab 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -143,11 +143,16 @@ bool TizenInputMethodContext::FilterEcoreEventKey(Ecore_Event_Key* event, bool is_down) { FT_ASSERT(imf_context_); FT_ASSERT(event); - +#ifdef WEARABLE_PROFILE + // Hardware keyboard is not supported on watch devices. + const char* device_name = "ime"; + bool is_ime = true; +#else const char* device_name = ecore_device_name_get(event->dev); bool is_ime = device_name ? strcmp(device_name, "ime") == 0 : true; +#endif - if (ShouldNotFilterEvent(event->key, is_ime)) { + if (ShouldIgnoreKey(event->key, is_ime)) { return false; } @@ -170,7 +175,7 @@ bool TizenInputMethodContext::FilterEcoreEventKey(Ecore_Event_Key* event, bool TizenInputMethodContext::FilterEvasEventKeyDown( Evas_Event_Key_Down* event) { - if (ShouldNotFilterEvent(event->key, true)) { + if (ShouldIgnoreKey(event->key, true)) { return false; } @@ -183,7 +188,7 @@ bool TizenInputMethodContext::FilterEvasEventKeyDown( } bool TizenInputMethodContext::FilterEvasEventKeyUp(Evas_Event_Key_Up* event) { - if (ShouldNotFilterEvent(event->key, true)) { + if (ShouldIgnoreKey(event->key, true)) { return false; } @@ -354,14 +359,8 @@ void TizenInputMethodContext::SetInputPanelOptions() { imf_context_, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC); } -bool TizenInputMethodContext::ShouldNotFilterEvent(std::string key, - bool is_ime) { - // Force redirect to HandleUnfilteredEvent(especially on TV) - // If you don't do this, it will affects the input panel. - // For example, when the left key of the input panel is pressed, the focus - // of the input panel is shifted to left! - // What we want is to move only the cursor on the text editor. - +bool TizenInputMethodContext::ShouldIgnoreKey(std::string key, bool is_ime) { + // The keys below should be handled in the text_input_channel. if (is_ime && (key == "Left" || key == "Right" || key == "Up" || key == "Down" || key == "End" || key == "Home" || key == "BackSpace" || key == "Delete")) { diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 63e7b93e0a51b..33db42d9f8e9c 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -73,7 +73,7 @@ class TizenInputMethodContext { void SetContextOptions(); void SetInputPanelOptions(); - bool ShouldNotFilterEvent(std::string key, bool is_ime); + bool ShouldIgnoreKey(std::string key, bool is_ime); Ecore_IMF_Context* imf_context_ = nullptr; OnCommit on_commit_; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index e77c908529474..5c2a46f7a64bd 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -421,7 +421,7 @@ void TizenWindowEcoreWl2::PrepareInputMethod() { [this]() { view_->OnComposeBegin(); }); input_method_context_->SetOnPreeditChanged( [this](std::string str, int cursor_pos) { - view_->OnComposeChanged(str, cursor_pos); + view_->OnComposeChange(str, cursor_pos); }); input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); input_method_context_->SetOnCommit( diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index 7eca84259111f..b0ce258264c28 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -19,7 +19,7 @@ static const int kScrollOffsetMultiplier = 20; uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) { uint32_t modifiers = 0; - if (evas_key_modifier_is_set(evas_modifier, "Contorol")) { + if (evas_key_modifier_is_set(evas_modifier, "Control")) { modifiers |= ECORE_EVENT_MODIFIER_CTRL; } if (evas_key_modifier_is_set(evas_modifier, "Alt")) { @@ -136,7 +136,7 @@ void TizenWindowElementary::SetWindowOptions() { } void TizenWindowElementary::RegisterEventHandlers() { - rotatoin_changed_callback_ = [](void* data, Evas_Object* object, + rotation_changed_callback_ = [](void* data, Evas_Object* object, void* event_info) { auto* self = reinterpret_cast(data); if (self->view_) { @@ -149,7 +149,7 @@ void TizenWindowElementary::RegisterEventHandlers() { } }; evas_object_smart_callback_add(elm_win_, "rotation,changed", - rotatoin_changed_callback_, this); + rotation_changed_callback_, this); evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN] = [](void* data, Evas* evas, Evas_Object* object, void* event_info) { @@ -240,7 +240,7 @@ void TizenWindowElementary::RegisterEventHandlers() { if (self->elm_win_ == object) { auto* key_event = reinterpret_cast(event_info); int handled = false; - if (self->input_method_context()->IsInputPanelShown()) { + if (self->input_method_context_->IsInputPanelShown()) { handled = self->input_method_context_->FilterEvasEventKeyDown(key_event); } @@ -284,7 +284,7 @@ void TizenWindowElementary::RegisterEventHandlers() { void TizenWindowElementary::UnregisterEventHandlers() { evas_object_smart_callback_del(elm_win_, "rotation,changed", - rotatoin_changed_callback_); + rotation_changed_callback_); evas_object_event_callback_del( elm_win_, EVAS_CALLBACK_MOUSE_DOWN, @@ -387,7 +387,7 @@ void TizenWindowElementary::PrepareInputMethod() { [this]() { view_->OnComposeBegin(); }); input_method_context_->SetOnPreeditChanged( [this](std::string str, int cursor_pos) { - view_->OnComposeChanged(str, cursor_pos); + view_->OnComposeChange(str, cursor_pos); }); input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); input_method_context_->SetOnCommit( diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index 97f358ff24c98..ac3fa9fcb4aeb 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -68,7 +68,7 @@ class TizenWindowElementary : public TizenWindow { Evas_Object* elm_win_ = nullptr; Evas_Object* image_ = nullptr; - Evas_Smart_Cb rotatoin_changed_callback_; + Evas_Smart_Cb rotation_changed_callback_; std::unordered_map evas_object_callbacks_; }; From 616ada24b707dfa0fa789d7acfdbebcd6e64a7d6 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 31 May 2022 11:42:18 +0900 Subject: [PATCH 05/12] Remove OnInputPanelStateChanged Signed-off-by: Boram Bae --- shell/platform/tizen/channels/key_event_channel.cc | 6 +++--- shell/platform/tizen/channels/text_input_channel.cc | 10 ---------- shell/platform/tizen/channels/text_input_channel.h | 7 ------- shell/platform/tizen/flutter_tizen_view.cc | 4 ---- shell/platform/tizen/flutter_tizen_view.h | 2 -- shell/platform/tizen/tizen_input_method_context.cc | 12 ------------ shell/platform/tizen/tizen_input_method_context.h | 6 ------ shell/platform/tizen/tizen_window_ecore_wl2.cc | 2 -- shell/platform/tizen/tizen_window_elementary.cc | 2 -- 9 files changed, 3 insertions(+), 48 deletions(-) diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index 499090048ee64..f76c26d57e8c8 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -273,10 +273,10 @@ void KeyEventChannel::SendKeyEvent(const char* key, key_code = iter2->second; } - int modifiers_key = 0; + int gtk_modifiers = 0; for (auto element : kEcoreModifierToGtkModifier) { if (element.first & modifiers) { - modifiers_key |= element.second; + gtk_modifiers |= element.second; } } @@ -292,7 +292,7 @@ void KeyEventChannel::SendKeyEvent(const char* key, event.AddMember(kUnicodeScalarValuesKey, unicode_scalar_values, allocator); event.AddMember(kKeyCodeKey, key_code, allocator); event.AddMember(kScanCodeKey, scan_code, allocator); - event.AddMember(kModifiersKey, modifiers_key, allocator); + event.AddMember(kModifiersKey, gtk_modifiers, allocator); if (is_down) { event.AddMember(kTypeKey, kKeyDown, allocator); } else { diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index b86fa81642541..8fd10040e2df0 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -108,16 +108,6 @@ void TextInputChannel::OnCommit(const std::string& str) { SendStateUpdate(); } -void TextInputChannel::OnInputPanelStateChanged(int state) { - if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) { - // Fallback for HW back-key. - input_method_context_->HideInputPanel(); - is_software_keyboard_showing_ = false; - } else { - is_software_keyboard_showing_ = true; - } -} - bool TextInputChannel::SendKeyEvent(const char* key, const char* string, const char* compose, diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index d4373fb4c6886..a960b79b3e0c5 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -22,8 +22,6 @@ class TextInputChannel { TizenInputMethodContext* input_method_context); virtual ~TextInputChannel(); - bool IsSoftwareKeyboardShowing() { return is_software_keyboard_showing_; } - void OnComposeBegin(); void OnComposeChange(const std::string& str, int cursor_pos); @@ -32,8 +30,6 @@ class TextInputChannel { void OnCommit(const std::string& str); - void OnInputPanelStateChanged(int state); - bool SendKeyEvent(const char* key, const char* string, const char* compose, @@ -74,9 +70,6 @@ class TextInputChannel { // The active client id. int client_id_ = 0; - // A flag indicating whether the software keyboard is being shown - bool is_software_keyboard_showing_ = false; - // An action requested by the user on the input client. See available options: // https://api.flutter.dev/flutter/services/TextInputAction-class.html std::string input_action_; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 5e4b124e59a87..e8ff698186a0d 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -251,10 +251,6 @@ void FlutterTizenView::OnCommit(const std::string& str) { text_input_channel_->OnCommit(str); } -void FlutterTizenView::OnInputPanelStateChanged(int state) { - text_input_channel_->OnInputPanelStateChanged(state); -} - void FlutterTizenView::SendInitialGeometry() { OnRotate(window_->GetRotation()); } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index f039f04d48f48..b91c6774efd03 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -96,8 +96,6 @@ class FlutterTizenView { void OnCommit(const std::string& str); - void OnInputPanelStateChanged(int state); - FlutterTransformation GetFlutterTransformation() { return flutter_transformation_; } diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 9e121d04a41ab..a615298da135d 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -312,17 +312,6 @@ void TizenInputMethodContext::RegisterEventCallbacks() { ecore_imf_context_event_callback_add( imf_context_, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, event_callbacks_[ECORE_IMF_CALLBACK_PREEDIT_CHANGED], this); - - // input panel state callback - ecore_imf_context_input_panel_event_callback_add( - imf_context_, ECORE_IMF_INPUT_PANEL_STATE_EVENT, - [](void* data, Ecore_IMF_Context* context, int value) { - auto* self = static_cast(data); - if (self->on_input_panel_state_changed_) { - self->on_input_panel_state_changed_(value); - } - }, - this); } void TizenInputMethodContext::UnregisterEventCallbacks() { @@ -339,7 +328,6 @@ void TizenInputMethodContext::UnregisterEventCallbacks() { ecore_imf_context_event_callback_del( imf_context_, ECORE_IMF_CALLBACK_PREEDIT_END, event_callbacks_[ECORE_IMF_CALLBACK_PREEDIT_END]); - ecore_imf_context_input_panel_event_callback_clear(imf_context_); } void TizenInputMethodContext::SetContextOptions() { diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 33db42d9f8e9c..e054ff9d3e25a 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -19,7 +19,6 @@ using OnCommit = std::function; using OnPreeditChanged = std::function; using OnPreeditStart = std::function; using OnPreeditEnd = std::function; -using OnInputPanelStateChanged = std::function; struct InputPanelGeometry { int32_t x = 0, y = 0, w = 0, h = 0; @@ -62,10 +61,6 @@ class TizenInputMethodContext { void SetOnPreeditEnd(OnPreeditEnd callback) { on_preedit_end_ = callback; } - void SetOnInputPanelStateChanged(OnInputPanelStateChanged callback) { - on_input_panel_state_changed_ = callback; - } - private: void RegisterEventCallbacks(); void UnregisterEventCallbacks(); @@ -80,7 +75,6 @@ class TizenInputMethodContext { OnPreeditChanged on_preedit_changed_; OnPreeditStart on_preedit_start_; OnPreeditEnd on_preedit_end_; - OnInputPanelStateChanged on_input_panel_state_changed_; std::unordered_map event_callbacks_; }; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 5c2a46f7a64bd..5f6bcf5721d27 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -426,8 +426,6 @@ void TizenWindowEcoreWl2::PrepareInputMethod() { input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); input_method_context_->SetOnCommit( [this](std::string str) { view_->OnCommit(str); }); - input_method_context_->SetOnInputPanelStateChanged( - [this](int state) { view_->OnInputPanelStateChanged(state); }); } } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index b0ce258264c28..c966b9adb2f5c 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -392,8 +392,6 @@ void TizenWindowElementary::PrepareInputMethod() { input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); input_method_context_->SetOnCommit( [this](std::string str) { view_->OnCommit(str); }); - input_method_context_->SetOnInputPanelStateChanged( - [this](int state) { view_->OnInputPanelStateChanged(state); }); } } // namespace flutter From 014fd60be4df480737b9fd9ff2bbcbab1b77edf2 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 31 May 2022 15:32:04 +0900 Subject: [PATCH 06/12] Remove assert Signed-off-by: Boram Bae --- shell/platform/tizen/tizen_input_method_context.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index a615298da135d..2119d5911742d 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -103,7 +103,6 @@ T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) { namespace flutter { TizenInputMethodContext::TizenInputMethodContext(uintptr_t window_id) { - FT_ASSERT(window_); ecore_imf_init(); const char* imf_id = ecore_imf_context_default_id_get(); From aed4ba332768fcd5db4188a9a684b750265b1885 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Tue, 31 May 2022 16:43:55 +0900 Subject: [PATCH 07/12] Use SendKey universally Signed-off-by: Boram Bae --- .../tizen/channels/key_event_channel.cc | 14 +++++++------- .../tizen/channels/key_event_channel.h | 14 +++++++------- .../tizen/channels/platform_view_channel.cc | 18 +++++++----------- .../tizen/channels/platform_view_channel.h | 12 ++++++------ .../tizen/channels/text_input_channel.cc | 12 ++++++------ .../tizen/channels/text_input_channel.h | 12 ++++++------ shell/platform/tizen/flutter_tizen_view.cc | 10 +++++----- .../tizen/public/flutter_platform_view.h | 17 ++++++----------- 8 files changed, 50 insertions(+), 59 deletions(-) diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index f76c26d57e8c8..67e76e0f08f75 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -254,13 +254,13 @@ KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger) KeyEventChannel::~KeyEventChannel() {} -void KeyEventChannel::SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down, - std::function callback) { +void KeyEventChannel::SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down, + std::function callback) { uint32_t scan_code = keycode; auto iter1 = kSymbolToScanCode.find(key); if (iter1 != kSymbolToScanCode.end()) { diff --git a/shell/platform/tizen/channels/key_event_channel.h b/shell/platform/tizen/channels/key_event_channel.h index 2df335c9ad9ef..5f788c90433cd 100644 --- a/shell/platform/tizen/channels/key_event_channel.h +++ b/shell/platform/tizen/channels/key_event_channel.h @@ -18,13 +18,13 @@ class KeyEventChannel { explicit KeyEventChannel(BinaryMessenger* messenger); virtual ~KeyEventChannel(); - void SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down, - std::function callback); + void SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down, + std::function callback); private: std::unique_ptr> channel_; diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 097cc19eef27e..160e47d8cc346 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -79,19 +79,15 @@ void PlatformViewChannel::ClearViewFactories() { view_factories_.clear(); } -void PlatformViewChannel::SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down) { +void PlatformViewChannel::SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) { PlatformView* view = FindFocusedView(); if (view) { - if (is_down) { - view->DispatchKeyDownEvent(key, string, compose, modifiers, keycode); - } else { - view->DispatchKeyUpEvent(key, string, compose, modifiers, keycode); - } + view->SendKey(key, string, compose, modifiers, keycode, is_down); } } diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index a7c2836dfc55a..9a59ddec1834b 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -28,12 +28,12 @@ class PlatformViewChannel { return view_factories_; } - void SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down); + void SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down); private: PlatformView* FindViewById(int view_id); diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 8fd10040e2df0..9a8b33f205bea 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -108,12 +108,12 @@ void TextInputChannel::OnCommit(const std::string& str) { SendStateUpdate(); } -bool TextInputChannel::SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down) { +bool TextInputChannel::SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) { if (active_model_ == nullptr) { return false; } diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index a960b79b3e0c5..58acc8e5d026a 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -30,12 +30,12 @@ class TextInputChannel { void OnCommit(const std::string& str); - bool SendKeyEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode, - bool is_down); + bool SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down); private: // Called when a method is called on |channel_|; diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index e8ff698186a0d..bb425ac7fb152 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -205,19 +205,19 @@ void FlutterTizenView::OnKey(const char* key, } if (text_input_channel_) { - if (text_input_channel_->SendKeyEvent(key, string, compose, modifiers, - keycode, is_down)) { + if (text_input_channel_->SendKey(key, string, compose, modifiers, keycode, + is_down)) { return; } } if (engine_->platform_view_channel()) { - engine_->platform_view_channel()->SendKeyEvent(key, string, compose, - modifiers, keycode, is_down); + engine_->platform_view_channel()->SendKey(key, string, compose, modifiers, + keycode, is_down); } if (engine_->key_event_channel()) { - engine_->key_event_channel()->SendKeyEvent( + engine_->key_event_channel()->SendKey( key, string, compose, modifiers, keycode, is_down, [engine = engine_.get(), symbol = std::string(key), is_down](bool handled) { diff --git a/shell/platform/tizen/public/flutter_platform_view.h b/shell/platform/tizen/public/flutter_platform_view.h index a87b9c197d979..a9aa7f2624394 100644 --- a/shell/platform/tizen/public/flutter_platform_view.h +++ b/shell/platform/tizen/public/flutter_platform_view.h @@ -45,17 +45,12 @@ class PlatformView { bool IsFocused() { return is_focused_; } - virtual void DispatchKeyDownEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode) = 0; - - virtual void DispatchKeyUpEvent(const char* key, - const char* string, - const char* compose, - uint32_t modifiers, - uint32_t keycode) = 0; + virtual void SendKey(const char* key, + const char* string, + const char* compose, + uint32_t modifiers, + uint32_t keycode, + bool is_down) = 0; private: flutter::PluginRegistrar* registrar_; From f414a145fe6a28a7915c3e3da2d8cbc487d40180 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 2 Jun 2022 10:55:06 +0900 Subject: [PATCH 08/12] Rename TizenInputMethodContext methods * From Filter to Handle Signed-off-by: Boram Bae --- shell/platform/tizen/channels/text_input_channel.cc | 6 ++---- shell/platform/tizen/tizen_input_method_context.cc | 6 +++--- shell/platform/tizen/tizen_input_method_context.h | 6 +++--- shell/platform/tizen/tizen_window_ecore_wl2.cc | 4 ++-- shell/platform/tizen/tizen_window_elementary.cc | 4 ++-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 9a8b33f205bea..8e8b393e4ca94 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -345,14 +345,12 @@ void TextInputChannel::HandleUnfilteredEvent(const char* key, } else if (key_str == "Return") { EnterPressed(); return; - } #ifdef TV_PROFILE - else if (key_str == "Select") { + } else if (key_str == "Select") { SelectPressed(); return; - } + } else { #endif - else { FT_LOG(Warn) << "Key[" << key << "] is unhandled."; } diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 2119d5911742d..72d7282d74486 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -138,7 +138,7 @@ TizenInputMethodContext::~TizenInputMethodContext() { ecore_imf_shutdown(); } -bool TizenInputMethodContext::FilterEcoreEventKey(Ecore_Event_Key* event, +bool TizenInputMethodContext::HandleEcoreEventKey(Ecore_Event_Key* event, bool is_down) { FT_ASSERT(imf_context_); FT_ASSERT(event); @@ -172,7 +172,7 @@ bool TizenInputMethodContext::FilterEcoreEventKey(Ecore_Event_Key* event, } } -bool TizenInputMethodContext::FilterEvasEventKeyDown( +bool TizenInputMethodContext::HandleEvasEventKeyDown( Evas_Event_Key_Down* event) { if (ShouldIgnoreKey(event->key, true)) { return false; @@ -186,7 +186,7 @@ bool TizenInputMethodContext::FilterEvasEventKeyDown( reinterpret_cast(&imf_event)); } -bool TizenInputMethodContext::FilterEvasEventKeyUp(Evas_Event_Key_Up* event) { +bool TizenInputMethodContext::HandleEvasEventKeyUp(Evas_Event_Key_Up* event) { if (ShouldIgnoreKey(event->key, true)) { return false; } diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index e054ff9d3e25a..55dd4a960c310 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -29,11 +29,11 @@ class TizenInputMethodContext { TizenInputMethodContext(uintptr_t window_id); ~TizenInputMethodContext(); - bool FilterEcoreEventKey(Ecore_Event_Key* event, bool is_down); + bool HandleEcoreEventKey(Ecore_Event_Key* event, bool is_down); - bool FilterEvasEventKeyDown(Evas_Event_Key_Down* event); + bool HandleEvasEventKeyDown(Evas_Event_Key_Down* event); - bool FilterEvasEventKeyUp(Evas_Event_Key_Up* event); + bool HandleEvasEventKeyUp(Evas_Event_Key_Up* event); InputPanelGeometry GetInputPanelGeometry(); diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index 5f6bcf5721d27..31ecc8a8fdc0a 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -246,7 +246,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (key_event->window == self->GetWindowId()) { int handled = false; if (self->input_method_context_->IsInputPanelShown()) { - handled = self->input_method_context_->FilterEcoreEventKey( + handled = self->input_method_context_->HandleEcoreEventKey( key_event, true); } if (!handled) { @@ -270,7 +270,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (key_event->window == self->GetWindowId()) { int handled = false; if (self->input_method_context_->IsInputPanelShown()) { - handled = self->input_method_context_->FilterEcoreEventKey( + handled = self->input_method_context_->HandleEcoreEventKey( key_event, false); } if (!handled) { diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index c966b9adb2f5c..c3e3341befb66 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -242,7 +242,7 @@ void TizenWindowElementary::RegisterEventHandlers() { int handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = - self->input_method_context_->FilterEvasEventKeyDown(key_event); + self->input_method_context_->HandleEvasEventKeyDown(key_event); } if (!handled) { self->view_->OnKey( @@ -266,7 +266,7 @@ void TizenWindowElementary::RegisterEventHandlers() { int handled = false; if (self->input_method_context_->IsInputPanelShown()) { handled = - self->input_method_context_->FilterEvasEventKeyUp(key_event); + self->input_method_context_->HandleEvasEventKeyUp(key_event); } if (!handled) { self->view_->OnKey( From e7062fab76d422ad268fa93e2e9854209399237d Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 2 Jun 2022 11:21:13 +0900 Subject: [PATCH 09/12] Change an argument name to scan_code Signed-off-by: Boram Bae --- shell/platform/tizen/channels/key_event_channel.cc | 3 +-- shell/platform/tizen/channels/key_event_channel.h | 2 +- shell/platform/tizen/channels/platform_view_channel.cc | 4 ++-- shell/platform/tizen/channels/platform_view_channel.h | 2 +- shell/platform/tizen/channels/text_input_channel.cc | 2 +- shell/platform/tizen/channels/text_input_channel.h | 2 +- shell/platform/tizen/flutter_tizen_view.cc | 10 +++++----- shell/platform/tizen/flutter_tizen_view.h | 2 +- shell/platform/tizen/public/flutter_platform_view.h | 2 +- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/shell/platform/tizen/channels/key_event_channel.cc b/shell/platform/tizen/channels/key_event_channel.cc index 67e76e0f08f75..041056338f743 100644 --- a/shell/platform/tizen/channels/key_event_channel.cc +++ b/shell/platform/tizen/channels/key_event_channel.cc @@ -258,10 +258,9 @@ void KeyEventChannel::SendKey(const char* key, const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down, std::function callback) { - uint32_t scan_code = keycode; auto iter1 = kSymbolToScanCode.find(key); if (iter1 != kSymbolToScanCode.end()) { scan_code = iter1->second; diff --git a/shell/platform/tizen/channels/key_event_channel.h b/shell/platform/tizen/channels/key_event_channel.h index 5f788c90433cd..c22d8c2eb46fc 100644 --- a/shell/platform/tizen/channels/key_event_channel.h +++ b/shell/platform/tizen/channels/key_event_channel.h @@ -22,7 +22,7 @@ class KeyEventChannel { const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down, std::function callback); diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 160e47d8cc346..e196d4198af15 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -83,11 +83,11 @@ void PlatformViewChannel::SendKey(const char* key, const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down) { PlatformView* view = FindFocusedView(); if (view) { - view->SendKey(key, string, compose, modifiers, keycode, is_down); + view->SendKey(key, string, compose, modifiers, scan_code, is_down); } } diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index 9a59ddec1834b..e847b4e18b92d 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -32,7 +32,7 @@ class PlatformViewChannel { const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down); private: diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 8e8b393e4ca94..a40e96364bc4a 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -112,7 +112,7 @@ bool TextInputChannel::SendKey(const char* key, const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down) { if (active_model_ == nullptr) { return false; diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 58acc8e5d026a..6a844f3384337 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -34,7 +34,7 @@ class TextInputChannel { const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down); private: diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index bb425ac7fb152..32e04361084de 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -197,15 +197,15 @@ void FlutterTizenView::OnKey(const char* key, const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down) { if (is_down) { FT_LOG(Info) << "Key symbol: " << key << ", code: 0x" << std::setw(8) - << std::setfill('0') << std::right << std::hex << keycode; + << std::setfill('0') << std::right << std::hex << scan_code; } if (text_input_channel_) { - if (text_input_channel_->SendKey(key, string, compose, modifiers, keycode, + if (text_input_channel_->SendKey(key, string, compose, modifiers, scan_code, is_down)) { return; } @@ -213,12 +213,12 @@ void FlutterTizenView::OnKey(const char* key, if (engine_->platform_view_channel()) { engine_->platform_view_channel()->SendKey(key, string, compose, modifiers, - keycode, is_down); + scan_code, is_down); } if (engine_->key_event_channel()) { engine_->key_event_channel()->SendKey( - key, string, compose, modifiers, keycode, is_down, + key, string, compose, modifiers, scan_code, is_down, [engine = engine_.get(), symbol = std::string(key), is_down](bool handled) { if (handled) { diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index b91c6774efd03..f31b597c85d3f 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -85,7 +85,7 @@ class FlutterTizenView { const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down); void OnComposeBegin(); diff --git a/shell/platform/tizen/public/flutter_platform_view.h b/shell/platform/tizen/public/flutter_platform_view.h index a9aa7f2624394..3da913557fb68 100644 --- a/shell/platform/tizen/public/flutter_platform_view.h +++ b/shell/platform/tizen/public/flutter_platform_view.h @@ -49,7 +49,7 @@ class PlatformView { const char* string, const char* compose, uint32_t modifiers, - uint32_t keycode, + uint32_t scan_code, bool is_down) = 0; private: From f00713764c77e0e435ca260c73cf79734efe48a7 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 2 Jun 2022 13:40:29 +0900 Subject: [PATCH 10/12] Update based on review Signed-off-by: Boram Bae --- shell/platform/tizen/channels/text_input_channel.cc | 8 ++++---- shell/platform/tizen/channels/text_input_channel.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index a40e96364bc4a..66497914d79a8 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -119,7 +119,7 @@ bool TextInputChannel::SendKey(const char* key, } if (is_down) { - HandleUnfilteredEvent(key, string, modifiers); + HandleKey(key, string, modifiers); } return true; @@ -300,9 +300,9 @@ void TextInputChannel::SendStateUpdate() { channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args)); } -void TextInputChannel::HandleUnfilteredEvent(const char* key, - const char* string, - uint32_t modifires) { +void 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; diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 6a844f3384337..25210519c1d3a 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -46,9 +46,7 @@ class TextInputChannel { // Sends the current state of |active_model_| to the Flutter engine. void SendStateUpdate(); - void HandleUnfilteredEvent(const char* key, - const char* string, - uint32_t modifires); + void HandleKey(const char* key, const char* string, uint32_t modifires); // Sends an action triggered by the Enter key to the Flutter engine. void EnterPressed(); From 12d051cf93dfb4d1b39fffbba03af5b1ff09b050 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 2 Jun 2022 14:31:15 +0900 Subject: [PATCH 11/12] Fix a typo Signed-off-by: Boram Bae --- shell/platform/tizen/channels/text_input_channel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 25210519c1d3a..4f9eea2034349 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -46,7 +46,7 @@ class TextInputChannel { // Sends the current state of |active_model_| to the Flutter engine. void SendStateUpdate(); - void HandleKey(const char* key, const char* string, uint32_t modifires); + void HandleKey(const char* key, const char* string, uint32_t modifiers); // Sends an action triggered by the Enter key to the Flutter engine. void EnterPressed(); From 36c0b8c351ab4ff8caf9c4693247d26fa9bb40b6 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Thu, 2 Jun 2022 15:19:37 +0900 Subject: [PATCH 12/12] Remove cache actions from build Signed-off-by: Boram Bae --- .github/workflows/build.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bc2c8e5ae7b6..b252049297288 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,13 +41,6 @@ jobs: path: src/flutter fetch-depth: 0 - - uses: actions/cache@v2 - with: - path: src/out/${{ env.OUTPUT_NAME }} - key: out-build-${{ env.OUTPUT_NAME }}-${{ github.sha }} - restore-keys: | - out-build-${{ env.OUTPUT_NAME }}- - - name: gclient sync run: | src/flutter/ci/tizen/gclient-prepare-sync.sh --reduce-deps --shallow-sync @@ -202,13 +195,6 @@ jobs: with: path: src/flutter - - uses: actions/cache@v2 - with: - path: src/out/${{ env.OUTPUT_NAME }} - key: out-macos-build-${{ env.OUTPUT_NAME }}-${{ github.sha }} - restore-keys: | - out-macos-build-${{ env.OUTPUT_NAME }}- - - name: install depot_tools run: | git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git