diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 63b1947eb0f76..4cbaf21734116 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -7,7 +7,9 @@ #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h" #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h" #include "flutter/shell/platform/common/cpp/json_method_codec.h" +#include "flutter/shell/platform/tizen/channels/text_input_channel.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" +#include "flutter/shell/platform/tizen/tizen_embedder_engine.h" #include "flutter/shell/platform/tizen/tizen_log.h" static constexpr char kChannelName[] = "flutter/platform_views"; @@ -63,8 +65,10 @@ flutter::EncodableList ExtractListFromMap( return flutter::EncodableList(); } -PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger) - : channel_( +PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger, + TizenEmbedderEngine* engine) + : engine_(engine), + channel_( std::make_unique>( messenger, kChannelName, &flutter::StandardMethodCodec::GetInstance())) { @@ -117,6 +121,7 @@ void PlatformViewChannel::HandleMethodCall( const auto method = call.method_name(); const auto& arguments = *call.arguments(); + FT_LOGD("method: %s", method.c_str()); if (method == "create") { std::string viewType = ExtractStringFromMap(arguments, "viewType"); int viewId = ExtractIntFromMap(arguments, "id"); @@ -151,10 +156,28 @@ void PlatformViewChannel::HandleMethodCall( channel_->InvokeMethod("viewFocused", std::move(id)); } + if (engine_ && engine_->text_input_channel) { + Ecore_IMF_Context* context = + engine_->text_input_channel->GetImfContext(); + viewInstance->SetSoftwareKeyboardContext(context); + } + result->Success(flutter::EncodableValue(viewInstance->GetTextureId())); } else { FT_LOGE("can't find view type = %s", viewType.c_str()); - result->Error("0", "can't find view type"); + result->Error("Can't find view type"); + } + } else if (method == "clearFocus") { + int viewId = -1; + if (std::holds_alternative(arguments)) { + viewId = std::get(arguments); + }; + auto it = view_instances_.find(viewId); + if (viewId >= 0 && it != view_instances_.end()) { + it->second->ClearFocus(); + result->Success(); + } else { + result->Error("Can't find view id"); } } else { int viewId = ExtractIntFromMap(arguments, "id"); @@ -165,7 +188,6 @@ void PlatformViewChannel::HandleMethodCall( it->second->Dispose(); result->Success(); } else if (method == "resize") { - FT_LOGD("PlatformViewChannel resize"); double width = ExtractDoubleFromMap(arguments, "width"); double height = ExtractDoubleFromMap(arguments, "height"); it->second->Resize(width, height); @@ -191,17 +213,12 @@ void PlatformViewChannel::HandleMethodCall( } else if (method == "setDirection") { FT_LOGD("PlatformViewChannel setDirection"); result->NotImplemented(); - } else if (method == "clearFocus") { - FT_LOGD("PlatformViewChannel clearFocus"); - it->second->ClearFocus(); - result->NotImplemented(); } else { FT_LOGD("Unimplemented method: %s", method.c_str()); result->NotImplemented(); } } else { - FT_LOGE("can't find view id"); - result->Error("0", "can't find view id"); + result->Error("Can't find view id"); } } } diff --git a/shell/platform/tizen/channels/platform_view_channel.h b/shell/platform/tizen/channels/platform_view_channel.h index 19eb3db99e27d..bb8f9494e87e4 100644 --- a/shell/platform/tizen/channels/platform_view_channel.h +++ b/shell/platform/tizen/channels/platform_view_channel.h @@ -13,11 +13,13 @@ #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h" #include "rapidjson/document.h" +class TizenEmbedderEngine; class PlatformView; class PlatformViewFactory; class PlatformViewChannel { public: - explicit PlatformViewChannel(flutter::BinaryMessenger* messenger); + explicit PlatformViewChannel(flutter::BinaryMessenger* messenger, + TizenEmbedderEngine* engine); virtual ~PlatformViewChannel(); void Dispose(); std::map>& ViewFactories() { @@ -29,6 +31,7 @@ class PlatformViewChannel { int CurrentFocusedViewId(); private: + TizenEmbedderEngine* engine_; std::unique_ptr> channel_; std::map> view_factories_; std::map view_instances_; diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 1a1e44404d9bf..85aae3236de0a 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -36,6 +36,8 @@ class TextInputChannel { return current_keyboard_geometry_; } + Ecore_IMF_Context* GetImfContext() { return imf_context_; } + int32_t rotation = 0; private: diff --git a/shell/platform/tizen/public/flutter_platform_view.h b/shell/platform/tizen/public/flutter_platform_view.h index 3c160e83ae8d9..6201cf2840b6a 100644 --- a/shell/platform/tizen/public/flutter_platform_view.h +++ b/shell/platform/tizen/public/flutter_platform_view.h @@ -5,6 +5,7 @@ #ifndef FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_ #define FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_ +#include #include #include #include @@ -38,6 +39,8 @@ class PlatformView { virtual void DispatchKeyDownEvent(Ecore_Event_Key* key) = 0; virtual void DispatchKeyUpEvent(Ecore_Event_Key* key) = 0; + virtual void SetSoftwareKeyboardContext(Ecore_IMF_Context* context) = 0; + private: flutter::PluginRegistrar* registrar_; int viewId_; diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index e97d58711be24..7806a916243c6 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -188,7 +188,7 @@ bool TizenEmbedderEngine::RunEngine( localization_channel->SendLocales(); lifecycle_channel = std::make_unique(flutter_engine); platform_view_channel = std::make_unique( - internal_plugin_registrar_->messenger()); + internal_plugin_registrar_->messenger(), this); key_event_handler_ = std::make_unique(this); touch_event_handler_ = std::make_unique(this);