Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call a method to set imf_context in platform view channel #24

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<flutter::MethodChannel<flutter::EncodableValue>>(
messenger, kChannelName,
&flutter::StandardMethodCodec::GetInstance())) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<int>(arguments)) {
viewId = std::get<int>(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");
Expand All @@ -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);
Expand All @@ -191,17 +213,12 @@ void PlatformViewChannel::HandleMethodCall(
} else if (method == "setDirection") {
FT_LOGD("PlatformViewChannel setDirection");
result->NotImplemented();
} else if (method == "clearFocus") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this ❓

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not remove it and moved just the location of the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. boy. Sorry! 😅

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");
}
}
}
5 changes: 4 additions & 1 deletion shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::unique_ptr<PlatformViewFactory>>& ViewFactories() {
Expand All @@ -29,6 +31,7 @@ class PlatformViewChannel {
int CurrentFocusedViewId();

private:
TizenEmbedderEngine* engine_;
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> channel_;
std::map<std::string, std::unique_ptr<PlatformViewFactory>> view_factories_;
std::map<int, PlatformView*> view_instances_;
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/tizen/channels/text_input_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class TextInputChannel {
return current_keyboard_geometry_;
}

Ecore_IMF_Context* GetImfContext() { return imf_context_; }

int32_t rotation = 0;

private:
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/tizen/public/flutter_platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Ecore_IMF.h>
#include <Ecore_Input.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool TizenEmbedderEngine::RunEngine(
localization_channel->SendLocales();
lifecycle_channel = std::make_unique<LifecycleChannel>(flutter_engine);
platform_view_channel = std::make_unique<PlatformViewChannel>(
internal_plugin_registrar_->messenger());
internal_plugin_registrar_->messenger(), this);

key_event_handler_ = std::make_unique<KeyEventHandler>(this);
touch_event_handler_ = std::make_unique<TouchEventHandler>(this);
Expand Down