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
22 changes: 13 additions & 9 deletions shell/platform/tizen/channels/platform_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "flutter/shell/platform/tizen/channels/tizen_shell.h"
#endif
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/tizen_view.h"
#include "flutter/shell/platform/tizen/tizen_window.h"

namespace flutter {

Expand Down Expand Up @@ -62,12 +64,12 @@ std::string text_clipboard = "";
} // namespace

PlatformChannel::PlatformChannel(BinaryMessenger* messenger,
TizenWindow* window)
TizenViewBase* view)
: channel_(std::make_unique<MethodChannel<rapidjson::Document>>(
messenger,
kChannelName,
&JsonMethodCodec::GetInstance())),
window_(window) {
view_(view) {
channel_->SetMethodCallHandler(
[this](const MethodCall<rapidjson::Document>& call,
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
Expand Down Expand Up @@ -156,8 +158,10 @@ void PlatformChannel::HandleMethodCall(
}

void PlatformChannel::SystemNavigatorPop() {
if (window_) {
if (view_->GetType() == TizenViewType::kWindow) {
ui_app_exit();
} else {
reinterpret_cast<TizenView*>(view_)->Unfocus();
}
}

Expand All @@ -174,13 +178,13 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) {
}

void PlatformChannel::RestoreSystemUiOverlays() {
if (!window_) {
if (view_->GetType() != TizenViewType::kWindow) {
return;
}

#ifdef COMMON_PROFILE
auto& shell = TizenShell::GetInstance();
shell.InitializeSoftkey(window_->GetWindowId());
shell.InitializeSoftkey(view_->GetWindowId());

if (shell.IsSoftkeyShown()) {
shell.ShowSoftkey();
Expand All @@ -192,13 +196,13 @@ void PlatformChannel::RestoreSystemUiOverlays() {

void PlatformChannel::SetEnabledSystemUiOverlays(
const std::vector<std::string>& overlays) {
if (!window_) {
if (view_->GetType() != TizenViewType::kWindow) {
return;
}

#ifdef COMMON_PROFILE
auto& shell = TizenShell::GetInstance();
shell.InitializeSoftkey(window_->GetWindowId());
shell.InitializeSoftkey(view_->GetWindowId());

if (std::find(overlays.begin(), overlays.end(), kSystemUiOverlayBottom) !=
overlays.end()) {
Expand All @@ -211,7 +215,7 @@ void PlatformChannel::SetEnabledSystemUiOverlays(

void PlatformChannel::SetPreferredOrientations(
const std::vector<std::string>& orientations) {
if (!window_) {
if (view_->GetType() != TizenViewType::kWindow) {
return;
}

Expand All @@ -230,7 +234,7 @@ void PlatformChannel::SetPreferredOrientations(
// default.
rotations = {0, 90, 180, 270};
}
window_->SetPreferredOrientations(rotations);
reinterpret_cast<TizenWindow*>(view_)->SetPreferredOrientations(rotations);
}

} // namespace flutter
9 changes: 4 additions & 5 deletions shell/platform/tizen/channels/platform_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/tizen/tizen_window.h"
#include "flutter/shell/platform/tizen/tizen_view_base.h"
#include "rapidjson/document.h"

namespace flutter {

class PlatformChannel {
public:
explicit PlatformChannel(BinaryMessenger* messenger, TizenWindow* window);
explicit PlatformChannel(BinaryMessenger* messenger, TizenViewBase* view);
virtual ~PlatformChannel();

private:
Expand All @@ -35,9 +35,8 @@ class PlatformChannel {

std::unique_ptr<MethodChannel<rapidjson::Document>> channel_;

// A reference to the window object managed by FlutterTizenView.
// This can be nullptr if the engine is running in headless mode.
TizenWindow* window_;
// A reference to the native view managed by FlutterTizenView.
TizenViewBase* view_;
};

} // namespace flutter
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/window_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WindowChannel {

std::unique_ptr<MethodChannel<EncodableValue>> channel_;

// A reference to the renderer object managed by FlutterTizenView.
// A reference to the native window managed by FlutterTizenView.
TizenWindow* window_;
};

Expand Down
5 changes: 2 additions & 3 deletions shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ void FlutterTizenView::SetEngine(std::unique_ptr<FlutterTizenEngine> engine) {

if (tizen_view_->GetType() == TizenViewType::kWindow) {
auto* window = reinterpret_cast<TizenWindow*>(tizen_view_.get());
platform_channel_ = std::make_unique<PlatformChannel>(messenger, window);
window_channel_ = std::make_unique<WindowChannel>(messenger, window);
} else {
platform_channel_ = std::make_unique<PlatformChannel>(messenger, nullptr);
window_channel_ = std::make_unique<WindowChannel>(messenger, nullptr);
}

platform_channel_ =
std::make_unique<PlatformChannel>(messenger, tizen_view_.get());
text_input_channel_ = std::make_unique<TextInputChannel>(
internal_plugin_registrar_->messenger(),
tizen_view_->input_method_context());
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/tizen/tizen_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ class TizenView : public TizenViewBase {

TizenViewType GetType() override { return TizenViewType::kView; };

void Unfocus() { focused_ = false; };

protected:
explicit TizenView(int32_t width, int32_t height)
: initial_width_(width), initial_height_(height) {}

int32_t initial_width_ = 0;
int32_t initial_height_ = 0;
bool focused_ = false;
};

} // namespace flutter
Expand Down
16 changes: 14 additions & 2 deletions shell/platform/tizen/tizen_view_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void TizenViewElementary::RegisterEventHandlers() {
void* event_info) {
auto* self = reinterpret_cast<TizenViewElementary*>(data);
if (self->view_delegate_) {
if (self->event_layer_ == object) {
if (self->event_layer_ == object && self->focused_) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Down*>(event_info);
bool handled = false;
key_event->event_flags =
Expand All @@ -269,7 +269,7 @@ void TizenViewElementary::RegisterEventHandlers() {
[](void* data, Evas* evas, Evas_Object* object, void* event_info) {
auto* self = reinterpret_cast<TizenViewElementary*>(data);
if (self->view_delegate_) {
if (self->event_layer_ == object) {
if (self->event_layer_ == object && self->focused_) {
auto* key_event = reinterpret_cast<Evas_Event_Key_Up*>(event_info);
bool handled = false;
key_event->event_flags = Evas_Event_Flags(key_event->event_flags |
Expand All @@ -290,6 +290,17 @@ void TizenViewElementary::RegisterEventHandlers() {
evas_object_event_callback_add(event_layer_, EVAS_CALLBACK_KEY_UP,
evas_object_callbacks_[EVAS_CALLBACK_KEY_UP],
this);

focused_callback_ = [](void* data, Evas_Object* object, void* event_info) {
auto* self = reinterpret_cast<TizenViewElementary*>(data);
if (self->view_delegate_) {
if (self->event_layer_ == object) {
self->focused_ = true;
}
}
};
evas_object_smart_callback_add(event_layer_, "focused", focused_callback_,
this);
}

void TizenViewElementary::UnregisterEventHandlers() {
Expand All @@ -312,6 +323,7 @@ void TizenViewElementary::UnregisterEventHandlers() {
evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN]);
evas_object_event_callback_del(event_layer_, EVAS_CALLBACK_KEY_UP,
evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]);
evas_object_smart_callback_del(event_layer_, "focused", focused_callback_);
}

TizenGeometry TizenViewElementary::GetGeometry() {
Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_view_elementary.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TizenViewElementary : public TizenView {
std::unordered_map<Evas_Callback_Type, Evas_Object_Event_Cb>
evas_object_callbacks_;
std::vector<Ecore_Event_Handler*> ecore_event_key_handlers_;
Evas_Smart_Cb focused_callback_ = nullptr;

bool scroll_hold_ = false;
};
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/tizen_window_elementary.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TizenWindowElementary : public TizenWindow {
Evas_Object* elm_win_ = nullptr;
Evas_Object* image_ = nullptr;

Evas_Smart_Cb rotation_changed_callback_;
Evas_Smart_Cb rotation_changed_callback_ = nullptr;
std::unordered_map<Evas_Callback_Type, Evas_Object_Event_Cb>
evas_object_callbacks_;
};
Expand Down