Skip to content

Refactor the key event handling #291

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

Merged
merged 12 commits into from
Jun 2, 2022
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
14 changes: 0 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -150,6 +152,7 @@ template("embedder") {
"dlog",
"ecore",
"ecore_imf",
"ecore_imf_evas",
"ecore_input",
"efl-extension",
"eina",
Expand Down
25 changes: 14 additions & 11 deletions shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,14 @@ KeyEventChannel::KeyEventChannel(BinaryMessenger* messenger)

KeyEventChannel::~KeyEventChannel() {}

void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
bool is_down,
std::function<void(bool)> callback) {
uint32_t scan_code = key->keycode;
auto iter1 = kSymbolToScanCode.find(key->key);
void KeyEventChannel::SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
bool is_down,
std::function<void(bool)> callback) {
auto iter1 = kSymbolToScanCode.find(key);
if (iter1 != kSymbolToScanCode.end()) {
scan_code = iter1->second;
}
Expand All @@ -269,16 +272,16 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
key_code = iter2->second;
}

int modifiers = 0;
int gtk_modifiers = 0;
for (auto element : kEcoreModifierToGtkModifier) {
if (element.first & key->modifiers) {
modifiers |= element.second;
if (element.first & modifiers) {
gtk_modifiers |= 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);
Expand All @@ -288,7 +291,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, gtk_modifiers, allocator);
if (is_down) {
event.AddMember(kTypeKey, kKeyDown, allocator);
} else {
Expand Down
12 changes: 7 additions & 5 deletions shell/platform/tizen/channels/key_event_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef EMBEDDER_KEY_EVENT_CHANNEL_H_
#define EMBEDDER_KEY_EVENT_CHANNEL_H_

#include <Ecore_Input.h>

#include <memory>

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

void SendKeyEvent(Ecore_Event_Key* event,
bool is_down,
std::function<void(bool)> callback);
void SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
bool is_down,
std::function<void(bool)> callback);

private:
std::unique_ptr<BasicMessageChannel<rapidjson::Document>> channel_;
Expand Down
13 changes: 7 additions & 6 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ void PlatformViewChannel::ClearViewFactories() {
view_factories_.clear();
}

void PlatformViewChannel::SendKeyEvent(Ecore_Event_Key* event, bool is_down) {
void PlatformViewChannel::SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
bool is_down) {
PlatformView* view = FindFocusedView();
if (view) {
if (is_down) {
view->DispatchKeyDownEvent(event);
} else {
view->DispatchKeyUpEvent(event);
}
view->SendKey(key, string, compose, modifiers, scan_code, is_down);
}
}

Expand Down
9 changes: 6 additions & 3 deletions shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef EMBEDDER_PLATFORM_VIEW_CHANNEL_H_
#define EMBEDDER_PLATFORM_VIEW_CHANNEL_H_

#include <Ecore_Input.h>

#include <map>
#include <memory>
#include <string>
Expand All @@ -30,7 +28,12 @@ class PlatformViewChannel {
return view_factories_;
}

void SendKeyEvent(Ecore_Event_Key* event, bool is_down);
void SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
bool is_down);

private:
PlatformView* FindViewById(int view_id);
Expand Down
Loading