Skip to content

Commit e534a7c

Browse files
authored
Refactor key event handling (#291)
* 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 <[email protected]>
1 parent cf2f9f1 commit e534a7c

24 files changed

+439
-294
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ jobs:
4141
path: src/flutter
4242
fetch-depth: 0
4343

44-
- uses: actions/cache@v2
45-
with:
46-
path: src/out/${{ env.OUTPUT_NAME }}
47-
key: out-build-${{ env.OUTPUT_NAME }}-${{ github.sha }}
48-
restore-keys: |
49-
out-build-${{ env.OUTPUT_NAME }}-
50-
5144
- name: gclient sync
5245
run: |
5346
src/flutter/ci/tizen/gclient-prepare-sync.sh --reduce-deps --shallow-sync
@@ -202,13 +195,6 @@ jobs:
202195
with:
203196
path: src/flutter
204197

205-
- uses: actions/cache@v2
206-
with:
207-
path: src/out/${{ env.OUTPUT_NAME }}
208-
key: out-macos-build-${{ env.OUTPUT_NAME }}-${{ github.sha }}
209-
restore-keys: |
210-
out-macos-build-${{ env.OUTPUT_NAME }}-
211-
212198
- name: install depot_tools
213199
run: |
214200
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

shell/platform/tizen/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ config("rootstrap_include_dirs") {
6565
"$custom_sysroot/usr/include/ecore-con-1",
6666
"$custom_sysroot/usr/include/ecore-evas-1",
6767
"$custom_sysroot/usr/include/ecore-file-1",
68+
"$custom_sysroot/usr/include/ecore-imf-evas-1",
69+
"$custom_sysroot/usr/include/ecore-input-evas-1",
6870
"$custom_sysroot/usr/include/edje-1",
6971
"$custom_sysroot/usr/include/eet-1",
7072
"$custom_sysroot/usr/include/efl-1/interfaces",
@@ -150,6 +152,7 @@ template("embedder") {
150152
"dlog",
151153
"ecore",
152154
"ecore_imf",
155+
"ecore_imf_evas",
153156
"ecore_input",
154157
"efl-extension",
155158
"eina",

shell/platform/tizen/channels/key_event_channel.cc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,14 @@ KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger)
254254

255255
KeyEventChannel::~KeyEventChannel() {}
256256

257-
void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
258-
bool is_down,
259-
std::function<void(bool)> callback) {
260-
uint32_t scan_code = key->keycode;
261-
auto iter1 = kSymbolToScanCode.find(key->key);
257+
void KeyEventChannel::SendKey(const char* key,
258+
const char* string,
259+
const char* compose,
260+
uint32_t modifiers,
261+
uint32_t scan_code,
262+
bool is_down,
263+
std::function<void(bool)> callback) {
264+
auto iter1 = kSymbolToScanCode.find(key);
262265
if (iter1 != kSymbolToScanCode.end()) {
263266
scan_code = iter1->second;
264267
}
@@ -269,16 +272,16 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
269272
key_code = iter2->second;
270273
}
271274

272-
int modifiers = 0;
275+
int gtk_modifiers = 0;
273276
for (auto element : kEcoreModifierToGtkModifier) {
274-
if (element.first & key->modifiers) {
275-
modifiers |= element.second;
277+
if (element.first & modifiers) {
278+
gtk_modifiers |= element.second;
276279
}
277280
}
278281

279282
uint32_t unicode_scalar_values = 0;
280-
if (key->compose) {
281-
unicode_scalar_values = Utf8ToUtf32CodePoint(key->compose);
283+
if (compose) {
284+
unicode_scalar_values = Utf8ToUtf32CodePoint(compose);
282285
}
283286

284287
rapidjson::Document event(rapidjson::kObjectType);
@@ -288,7 +291,7 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
288291
event.AddMember(kUnicodeScalarValuesKey, unicode_scalar_values, allocator);
289292
event.AddMember(kKeyCodeKey, key_code, allocator);
290293
event.AddMember(kScanCodeKey, scan_code, allocator);
291-
event.AddMember(kModifiersKey, modifiers, allocator);
294+
event.AddMember(kModifiersKey, gtk_modifiers, allocator);
292295
if (is_down) {
293296
event.AddMember(kTypeKey, kKeyDown, allocator);
294297
} else {

shell/platform/tizen/channels/key_event_channel.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#ifndef EMBEDDER_KEY_EVENT_CHANNEL_H_
66
#define EMBEDDER_KEY_EVENT_CHANNEL_H_
77

8-
#include <Ecore_Input.h>
9-
108
#include <memory>
119

1210
#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
@@ -20,9 +18,13 @@ class KeyEventChannel {
2018
explicit KeyEventChannel(BinaryMessenger* messenger);
2119
virtual ~KeyEventChannel();
2220

23-
void SendKeyEvent(Ecore_Event_Key* event,
24-
bool is_down,
25-
std::function<void(bool)> callback);
21+
void SendKey(const char* key,
22+
const char* string,
23+
const char* compose,
24+
uint32_t modifiers,
25+
uint32_t scan_code,
26+
bool is_down,
27+
std::function<void(bool)> callback);
2628

2729
private:
2830
std::unique_ptr<BasicMessageChannel<rapidjson::Document>> channel_;

shell/platform/tizen/channels/platform_view_channel.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ void PlatformViewChannel::ClearViewFactories() {
7979
view_factories_.clear();
8080
}
8181

82-
void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* event, bool is_down) {
82+
void PlatformViewChannel::SendKey(const char* key,
83+
const char* string,
84+
const char* compose,
85+
uint32_t modifiers,
86+
uint32_t scan_code,
87+
bool is_down) {
8388
PlatformView* view = FindFocusedView();
8489
if (view) {
85-
if (is_down) {
86-
view->DispatchKeyDownEvent(event);
87-
} else {
88-
view->DispatchKeyUpEvent(event);
89-
}
90+
view->SendKey(key, string, compose, modifiers, scan_code, is_down);
9091
}
9192
}
9293

shell/platform/tizen/channels/platform_view_channel.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#ifndef EMBEDDER_PLATFORM_VIEW_CHANNEL_H_
66
#define EMBEDDER_PLATFORM_VIEW_CHANNEL_H_
77

8-
#include <Ecore_Input.h>
9-
108
#include <map>
119
#include <memory>
1210
#include <string>
@@ -30,7 +28,12 @@ class PlatformViewChannel {
3028
return view_factories_;
3129
}
3230

33-
void SendKeyEvent(Ecore_Event_Key* event, bool is_down);
31+
void SendKey(const char* key,
32+
const char* string,
33+
const char* compose,
34+
uint32_t modifiers,
35+
uint32_t scan_code,
36+
bool is_down);
3437

3538
private:
3639
PlatformView* FindViewById(int view_id);

0 commit comments

Comments
 (0)