Skip to content
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
20 changes: 20 additions & 0 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
#include "flutter/shell/platform/tizen/tizen_view.h"
#ifdef NUI_SUPPORT
#include "flutter/shell/platform/tizen/tizen_view_nui.h"
#endif
#include "flutter/shell/platform/tizen/tizen_window.h"
#ifndef WEARABLE_PROFILE
#include "flutter/shell/platform/tizen/tizen_window_ecore_wl2.h"
Expand Down Expand Up @@ -266,13 +269,30 @@ void FlutterDesktopViewOnPointerEvent(FlutterDesktopViewRef view,
}

void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view,
const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down) {
#ifdef NUI_SUPPORT
auto* tizen_view = reinterpret_cast<flutter::TizenViewBase*>(
ViewFromHandle(view)->tizen_view());

if (tizen_view->GetType() == flutter::TizenViewType::kView &&
ViewFromHandle(view)->engine()->renderer()->type() ==
FlutterDesktopRendererType::kEGL) {
reinterpret_cast<flutter::TizenViewNui*>(tizen_view)
->OnKey(device_name, device_class, device_subclass, key, string,
nullptr, modifiers, scan_code, timestamp, is_down);
}
#else
ViewFromHandle(view)->OnKey(key, string, nullptr, modifiers, scan_code,
is_down);
#endif
}

void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view, bool focused) {
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/tizen/public/flutter_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@ FLUTTER_EXPORT void FlutterDesktopViewOnPointerEvent(
int32_t device_id);

FLUTTER_EXPORT void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view,
const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down);

FLUTTER_EXPORT void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view,
Expand Down
51 changes: 51 additions & 0 deletions shell/platform/tizen/tizen_input_method_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ TizenInputMethodContext::TizenInputMethodContext(uintptr_t window_id) {
TizenInputMethodContext::~TizenInputMethodContext() {
UnregisterEventCallbacks();

#ifdef NUI_SUPPORT
if (ecore_device_) {
ecore_device_del(ecore_device_);
}
#endif

if (imf_context_) {
ecore_imf_context_del(imf_context_);
}
Expand Down Expand Up @@ -191,6 +197,51 @@ bool TizenInputMethodContext::HandleEvasEventKeyUp(Evas_Event_Key_Up* event) {
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
}

#ifdef NUI_SUPPORT
bool TizenInputMethodContext::HandleNuiKeyEvent(const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down) {
Comment on lines +201 to +209
Copy link
Member

Choose a reason for hiding this comment

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

This method (or TizenViewNui::OnKey) has too many parameters. They may be wrapped up into a class or struct but I'm not sure if it's a good solution.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are all Ecore_Events, but NUI doesn't provide all properties of EcoreEvent (maybe?).
I think we can add a struct NuiEventKey(?) structure, but I'd like to improve it in another PR if needed.

Ecore_Event_Key event;
event.keyname = event.key = key ? key : "";
event.string = string ? string : "";
event.modifiers = modifiers;
event.keycode = scan_code;
event.timestamp = timestamp;
if (device_name) {
if (!ecore_device_) {
ecore_device_ = ecore_device_add();
}

event.dev = ecore_device_;
ecore_device_name_set(event.dev, device_name);
ecore_device_class_set(event.dev,
static_cast<Ecore_IMF_Device_Class>(device_class));
ecore_device_subclass_set(
event.dev, static_cast<Ecore_IMF_Device_Subclass>(device_subclass));
}

if (is_down) {
Ecore_IMF_Event_Key_Down imf_event =
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Down>(&event);
return ecore_imf_context_filter_event(
imf_context_, ECORE_IMF_EVENT_KEY_DOWN,
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
} else {
Ecore_IMF_Event_Key_Up imf_event =
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Up>(&event);
return ecore_imf_context_filter_event(
imf_context_, ECORE_IMF_EVENT_KEY_UP,
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
}
}
#endif

InputPanelGeometry TizenInputMethodContext::GetInputPanelGeometry() {
FT_ASSERT(imf_context_);
InputPanelGeometry geometry;
Expand Down
15 changes: 15 additions & 0 deletions shell/platform/tizen/tizen_input_method_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ class TizenInputMethodContext {

bool HandleEvasEventKeyUp(Evas_Event_Key_Up* event);

#ifdef NUI_SUPPORT
bool HandleNuiKeyEvent(const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down);
#endif

InputPanelGeometry GetInputPanelGeometry();

void ResetInputMethodContext();
Expand Down Expand Up @@ -70,6 +82,9 @@ class TizenInputMethodContext {
void SetContextOptions();
void SetInputPanelOptions();

#ifdef NUI_SUPPORT
Ecore_Device* ecore_device_ = nullptr;
#endif
Ecore_IMF_Context* imf_context_ = nullptr;
OnCommit on_commit_;
OnPreeditChanged on_preedit_changed_;
Expand Down
23 changes: 23 additions & 0 deletions shell/platform/tizen/tizen_view_nui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ void TizenViewNui::RequestRendering() {
rendering_callback_->Trigger();
}

void TizenViewNui::OnKey(const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down) {
bool handled = false;

if (input_method_context_->IsInputPanelShown()) {
handled = input_method_context_->HandleNuiKeyEvent(
device_name, device_class, device_subclass, key, string, modifiers,
scan_code, timestamp, is_down);
}

if (!handled) {
view_delegate_->OnKey(key, string, compose, modifiers, scan_code, is_down);
}
}

void TizenViewNui::PrepareInputMethod() {
input_method_context_ =
std::make_unique<TizenInputMethodContext>(GetWindowId());
Expand Down
11 changes: 11 additions & 0 deletions shell/platform/tizen/tizen_view_nui.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ class TizenViewNui : public TizenView {

void RequestRendering();

void OnKey(const char* device_name,
uint32_t device_class,
uint32_t device_subclass,
const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
size_t timestamp,
bool is_down);

private:
void RegisterEventHandlers();

Expand Down