Skip to content

Commit 6280c13

Browse files
authored
Refactor TextInputChannel (flutter-tizen#142)
* Refactor TextInputChannel * Introduce TizenInputMethodContext * Do not handle key event for PlatformView in TextInputChannel Each PlatformView must Implement to handle key event. After this patch, the input panel of webview_flutter does not work properly. but it have to handle every key event on itself like webview_flutter_ewk does. Signed-off-by: Boram Bae <[email protected]> * Remove unnecessary PlatformView APIs Signed-off-by: Boram Bae <[email protected]> * Tidy up based on review Signed-off-by: Boram Bae <[email protected]> * Always Send key event to TextInputChannel * Use SendKeyEvent as the method name for handling key events like others. * SendKeyEvent returns true if the key event has been handled. Signed-off-by: Boram Bae <[email protected]> * Use #if defined() instead of #ifdef Signed-off-by: Boram Bae <[email protected]> * Rename to ShouldNotFilterEvent Signed-off-by: Boram Bae <[email protected]>
1 parent 322e67b commit 6280c13

10 files changed

+559
-544
lines changed

shell/platform/tizen/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ _flutter_tizen_source = [
3838
"flutter_tizen_texture_registrar.cc",
3939
"key_event_handler.cc",
4040
"tizen_event_loop.cc",
41+
"tizen_input_method_context.cc",
4142
"tizen_renderer.cc",
4243
"touch_event_handler.cc",
4344
]

shell/platform/tizen/channels/platform_view_channel.cc

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
99
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"
1010
#include "flutter/shell/platform/common/json_method_codec.h"
11-
#include "flutter/shell/platform/tizen/channels/text_input_channel.h"
1211
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
1312
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
1413
#include "flutter/shell/platform/tizen/tizen_log.h"
@@ -33,10 +32,8 @@ bool GetValueFromEncodableMap(const EncodableValue& arguments,
3332
return false;
3433
}
3534

36-
PlatformViewChannel::PlatformViewChannel(BinaryMessenger* messenger,
37-
FlutterTizenEngine* engine)
38-
: engine_(engine),
39-
channel_(std::make_unique<MethodChannel<EncodableValue>>(
35+
PlatformViewChannel::PlatformViewChannel(BinaryMessenger* messenger)
36+
: channel_(std::make_unique<MethodChannel<EncodableValue>>(
4037
messenger,
4138
kChannelName,
4239
&StandardMethodCodec::GetInstance())) {
@@ -95,23 +92,6 @@ void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) {
9592
}
9693
}
9794

98-
void PlatformViewChannel::DispatchCompositionUpdateEvent(
99-
const std::string& key) {
100-
auto instances = ViewInstances();
101-
auto it = instances.find(CurrentFocusedViewId());
102-
if (it != instances.end()) {
103-
it->second->DispatchCompositionUpdateEvent(key.c_str(), key.size());
104-
}
105-
}
106-
107-
void PlatformViewChannel::DispatchCompositionEndEvent(const std::string& key) {
108-
auto instances = ViewInstances();
109-
auto it = instances.find(CurrentFocusedViewId());
110-
if (it != instances.end()) {
111-
it->second->DispatchCompositionEndEvent(key.c_str(), key.size());
112-
}
113-
}
114-
11595
int PlatformViewChannel::CurrentFocusedViewId() {
11696
for (auto it = view_instances_.begin(); it != view_instances_.end(); it++) {
11797
if (it->second->IsFocused()) {
@@ -162,12 +142,6 @@ void PlatformViewChannel::HandleMethodCall(
162142
if (view_instance) {
163143
view_instances_.insert(
164144
std::pair<int, PlatformView*>(view_id, view_instance));
165-
166-
if (engine_ && engine_->text_input_channel) {
167-
Ecore_IMF_Context* context =
168-
engine_->text_input_channel->GetImfContext();
169-
view_instance->SetSoftwareKeyboardContext(context);
170-
}
171145
result->Success(EncodableValue(view_instance->GetTextureId()));
172146
} else {
173147
result->Error("Can't create a webview instance!!");
@@ -264,5 +238,4 @@ void PlatformViewChannel::HandleMethodCall(
264238
}
265239
}
266240
}
267-
268241
} // namespace flutter

shell/platform/tizen/channels/platform_view_channel.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ class PlatformViewFactory;
2020

2121
namespace flutter {
2222

23-
class FlutterTizenEngine;
24-
2523
class PlatformViewChannel {
2624
public:
27-
explicit PlatformViewChannel(BinaryMessenger* messenger,
28-
FlutterTizenEngine* engine);
25+
explicit PlatformViewChannel(BinaryMessenger* messenger);
2926
virtual ~PlatformViewChannel();
3027

3128
void Dispose();
@@ -41,14 +38,10 @@ class PlatformViewChannel {
4138
void SendKeyEvent(Ecore_Event_Key* key, bool is_down);
4239
int CurrentFocusedViewId();
4340

44-
void DispatchCompositionUpdateEvent(const std::string& key);
45-
void DispatchCompositionEndEvent(const std::string& key);
46-
4741
private:
4842
void HandleMethodCall(const MethodCall<EncodableValue>& call,
4943
std::unique_ptr<MethodResult<EncodableValue>> result);
5044

51-
FlutterTizenEngine* engine_;
5245
std::unique_ptr<MethodChannel<EncodableValue>> channel_;
5346
std::map<std::string, std::unique_ptr<PlatformViewFactory>> view_factories_;
5447
std::map<int, PlatformView*> view_instances_;

0 commit comments

Comments
 (0)