Skip to content
1 change: 1 addition & 0 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ template("embedder") {
sources += [
"flutter_tizen_elementary.cc",
"tizen_renderer_evas_gl.cc",
"tizen_view_elementary.cc",
"tizen_window_elementary.cc",
]

Expand Down
10 changes: 5 additions & 5 deletions shell/platform/tizen/channels/window_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void WindowChannel::HandleMethodCall(
const std::string& method_name = method_call.method_name();

if (method_name == "getWindowGeometry") {
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
TizenGeometry geometry = window_->GetGeometry();
EncodableMap map;
map[EncodableValue("x")] = EncodableValue(geometry.left);
map[EncodableValue("y")] = EncodableValue(geometry.top);
Expand All @@ -57,9 +57,9 @@ void WindowChannel::HandleMethodCall(
EncodableValueHolder<int32_t> width(arguments, "width");
EncodableValueHolder<int32_t> height(arguments, "height");

TizenWindow::Geometry geometry = window_->GetWindowGeometry();
// FIXME: Use SetWindowGeometry() instead of OnGeometryChanged()
// After the SetWindowGeometry was successfully executed, I expected a
TizenGeometry geometry = window_->GetGeometry();
// FIXME: Use SetGeometry() instead of OnGeometryChanged()
// After the SetGeometry was successfully executed, I expected a
// handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't.
window_->OnGeometryChanged({
x ? *x : geometry.left,
Expand All @@ -70,7 +70,7 @@ void WindowChannel::HandleMethodCall(
result->Success();
#endif
} else if (method_name == "getScreenGeometry") {
TizenWindow::Geometry geometry = window_->GetScreenGeometry();
TizenGeometry geometry = window_->GetScreenGeometry();
EncodableMap map;
map[EncodableValue("width")] = EncodableValue(geometry.width);
map[EncodableValue("height")] = EncodableValue(geometry.height);
Expand Down
7 changes: 6 additions & 1 deletion shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) {

void* FlutterDesktopPluginRegistrarGetNativeWindow(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->view()->window()->GetWindowHandle();
flutter::TizenViewBase* tizen_view = registrar->engine->view()->tizen_view();
if (tizen_view->GetType() == flutter::TizenViewType::kWindow) {
auto* window = reinterpret_cast<flutter::TizenWindow*>(tizen_view);
return window->GetWindowHandle();
}
return nullptr;
}

void FlutterDesktopPluginRegistrarEnableInputBlocking(
Expand Down
29 changes: 23 additions & 6 deletions shell/platform/tizen/flutter_tizen_ecore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/flutter_tizen_view.h"
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/tizen_window_ecore_wl2.h"

namespace {
Expand All @@ -24,12 +25,9 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) {
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
const FlutterDesktopWindowProperties& window_properties,
FlutterDesktopEngineRef engine) {
flutter::TizenWindow::Geometry window_geometry = {
window_properties.x,
window_properties.y,
window_properties.width,
window_properties.height,
};
flutter::TizenGeometry window_geometry = {
window_properties.x, window_properties.y, window_properties.width,
window_properties.height};

std::unique_ptr<flutter::TizenWindow> window =
std::make_unique<flutter::TizenWindowEcoreWl2>(
Expand All @@ -52,3 +50,22 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(

return HandleForView(view.release());
}

FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent(
const FlutterDesktopViewProperties& view_properties,
FlutterDesktopEngineRef engine,
void* parent) {
FT_LOG(Warn) << "Not applicable!";
return nullptr;
}

void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) {
FT_LOG(Warn) << "Not applicable!";
return nullptr;
}

void FlutterDesktopViewResize(FlutterDesktopViewRef view_ref,
int32_t width,
int32_t height) {
FT_LOG(Warn) << "Not applicable!";
}
55 changes: 49 additions & 6 deletions shell/platform/tizen/flutter_tizen_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/flutter_tizen_view.h"
#include "flutter/shell/platform/tizen/tizen_view_elementary.h"
#include "flutter/shell/platform/tizen/tizen_window_elementary.h"

namespace {
Expand All @@ -24,12 +25,9 @@ FlutterDesktopViewRef HandleForView(flutter::FlutterTizenView* view) {
FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
const FlutterDesktopWindowProperties& window_properties,
FlutterDesktopEngineRef engine) {
flutter::TizenWindow::Geometry window_geometry = {
window_properties.x,
window_properties.y,
window_properties.width,
window_properties.height,
};
flutter::TizenGeometry window_geometry = {
window_properties.x, window_properties.y, window_properties.width,
window_properties.height};

std::unique_ptr<flutter::TizenWindow> window =
std::make_unique<flutter::TizenWindowElementary>(
Expand All @@ -52,3 +50,48 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(

return HandleForView(view.release());
}

FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent(
const FlutterDesktopViewProperties& view_properties,
FlutterDesktopEngineRef engine,
void* parent) {
std::unique_ptr<flutter::TizenViewBase> tizen_view =
std::make_unique<flutter::TizenViewElementary>(
view_properties.width, view_properties.height,
static_cast<Evas_Object*>(parent));

auto view =
std::make_unique<flutter::FlutterTizenView>(std::move(tizen_view));

// Take ownership of the engine, starting it if necessary.
view->SetEngine(
std::unique_ptr<flutter::FlutterTizenEngine>(EngineFromHandle(engine)));
view->CreateRenderSurface();
if (!view->engine()->IsRunning()) {
if (!view->engine()->RunEngine()) {
return nullptr;
}
}

view->SendInitialGeometry();

return HandleForView(view.release());
}

void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) {
auto* view = reinterpret_cast<flutter::FlutterTizenView*>(view_ref);
if (view->tizen_view()->GetType() == flutter::TizenViewType::kView) {
auto* tizen_view =
reinterpret_cast<flutter::TizenView*>(view->tizen_view());
return tizen_view->GetRenderTargetContainer();
}
return nullptr;
}

void FlutterDesktopViewResize(FlutterDesktopViewRef view_ref,
int32_t width,
int32_t height) {
auto* view = reinterpret_cast<flutter::FlutterTizenView*>(view_ref);
flutter::TizenGeometry view_geometry = {0, 0, width, height};
view->tizen_view()->OnGeometryChanged(view_geometry);
Copy link

Choose a reason for hiding this comment

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

In my opinion, the embedder APIs related to View should be something like C wrapper of FlutterTizenView interface.
so, I believe that to provide the resizing, it has to work internally through FlutterTizenView's interface.

This is the basic design I was initially thinking of, so it's open for discussion and you don't need to fix it right away. I'm curious about your opinion.

Copy link
Member

Choose a reason for hiding this comment

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

I don't agree. FlutterTizenView is simply an abstraction layer for a Flutter view and it should not be considered as a wrapper of TizenView.

Copy link

Choose a reason for hiding this comment

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

FlutterTizenView is simply an abstraction layer for a Flutter view and it should not be considered as a wrapper of TizenView.

What you said is a simple principle I came up with when I first designed it.
When I first designed FlutterDeskopViewXXX APIs, I had the following design in mind.

void FlutterDesktopViewXXX()
{
   ...
    view->XXX()
   ...
}

Currently, FlutterTizenView may have different detailed behaviors depending on TizenViewType.
So I think this idea may not be suitable. That's why I was curious about your thoughts :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree to reduce the abstraction level (depth) of required FlutterDesktopViewXXX.
In the case of resize rather than simple property change, I think it is better to handle it with view->Rsize().
If the ViewType check is handled inside the FlutterTizenView, I think it is easy to fix when the type check is no longer needed through refactoring.

}
3 changes: 1 addition & 2 deletions shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions(
bridge->GetFlutterPlatformNodeDelegateFromID(0);
std::shared_ptr<FlutterPlatformWindowDelegateTizen> window =
FlutterPlatformAppDelegateTizen::GetInstance().GetWindow().lock();
TizenWindow::Geometry geometry =
engine->view_->window()->GetWindowGeometry();
TizenGeometry geometry = engine->view_->tizen_view()->GetGeometry();
window->SetGeometry(geometry.left, geometry.top, geometry.width,
geometry.height);
window->SetRootNode(root);
Expand Down
67 changes: 45 additions & 22 deletions shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "flutter_tizen_view.h"

#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/tizen_view.h"
#include "flutter/shell/platform/tizen/tizen_window.h"

namespace {

Expand Down Expand Up @@ -40,10 +42,10 @@ const std::vector<std::string> kBindableSystemKeys = {

namespace flutter {

FlutterTizenView::FlutterTizenView(std::unique_ptr<TizenWindow> window)
: window_(std::move(window)) {
window_->SetView(this);
window_->BindKeys(kBindableSystemKeys);
FlutterTizenView::FlutterTizenView(std::unique_ptr<TizenViewBase> tizen_view)
: tizen_view_(std::move(tizen_view)) {
tizen_view_->SetView(this);
tizen_view_->BindKeys(kBindableSystemKeys);
Copy link

Choose a reason for hiding this comment

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

When the type of tizen_view_ is not window, I don't think this is the role of the Embedder anymore. I think it should be fixed later.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that makes sense. I think we can move BindKeys from TizenViewBase to TizenWindow.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the view also needs a bind to a special key.
We may also need the TV remote's back key or other special key inside the View.
Since key binding is platform dependent, I think that the information provided for VD profile can be same with either Window or View.

This has already been talked about in private chats.
If necessary, I hope this is discussed in a separate PR regarding special key bindings.

Copy link

Choose a reason for hiding this comment

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

Yes, we can handle it in another PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think the view also needs a bind to a special key.
We may also need the TV remote's back key or other special key inside the View.
Since key binding is platform dependent, I think that the information provided for VD profile can be same with either Window or View.

Sorry. I don't still get why it should be the embedder's role to register the special keys. Isn't is possible for the parent app to call eext_win_keygrab_set with its own window as necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry. I don't still get why it should be the embedder's role to register the special keys. Isn't is possible for the parent app to call eext_win_keygrab_set with its own window as necessary?

Using eext_win_keygrab_set, the app user can also bind a key to the app window.

my opinion is that the flutter app(window and view) created with flutter-tizen can provide the same key bind within the VD profile. If the user has experienced that BackKey works in flutter-app (win), but does not add it to the app in the view, it may not work. Of course, not binding to the app's window may mean that a special key is not used.
This is just my opinion.

however, it seems problematic for the view to modify the properties of the window.
I can also delete the view's bind code from this PR. Should I do that now?
@bbrto21 told me on chat that he would proceed with the modify related to key bind.

}

FlutterTizenView::~FlutterTizenView() {}
Expand All @@ -57,19 +59,34 @@ void FlutterTizenView::SetEngine(std::unique_ptr<FlutterTizenEngine> engine) {

// Set up window dependent channels.
BinaryMessenger* messenger = internal_plugin_registrar_->messenger();
platform_channel_ =
std::make_unique<PlatformChannel>(messenger, window_.get());
window_channel_ = std::make_unique<WindowChannel>(messenger, window_.get());

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);
}

text_input_channel_ = std::make_unique<TextInputChannel>(
internal_plugin_registrar_->messenger(), window_->input_method_context());
internal_plugin_registrar_->messenger(),
tizen_view_->input_method_context());
}

void FlutterTizenView::CreateRenderSurface() {
if (engine_ && engine_->renderer()) {
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
engine_->renderer()->CreateSurface(window_->GetRenderTarget(),
window_->GetRenderTargetDisplay(),
geometry.width, geometry.height);
TizenGeometry geometry = tizen_view_->GetGeometry();
if (tizen_view_->GetType() == TizenViewType::kWindow) {
auto* window = reinterpret_cast<TizenWindow*>(tizen_view_.get());
engine_->renderer()->CreateSurface(window->GetRenderTarget(),
window->GetRenderTargetDisplay(),
geometry.width, geometry.height);
} else {
auto* tizen_view = reinterpret_cast<TizenView*>(tizen_view_.get());
engine_->renderer()->CreateSurface(tizen_view->GetRenderTarget(), nullptr,
geometry.width, geometry.height);
}
}
}

Expand Down Expand Up @@ -111,16 +128,15 @@ void FlutterTizenView::OnResize(int32_t left,
std::swap(width, height);
}

window_->ResizeRenderTargetWithRotation({left, top, width, height},
rotation_degree_);
tizen_view_->ResizeWithRotation({left, top, width, height}, rotation_degree_);
SendWindowMetrics(left, top, width, height, 0.0);
}

void FlutterTizenView::OnRotate(int32_t degree) {
rotation_degree_ = degree;
// Compute renderer transformation based on the angle of rotation.
double rad = (360 - rotation_degree_) * M_PI / 180;
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
TizenGeometry geometry = tizen_view_->GetGeometry();
int32_t width = geometry.width;
int32_t height = geometry.height;

Expand All @@ -144,8 +160,8 @@ void FlutterTizenView::OnRotate(int32_t degree) {
std::swap(width, height);
}

window_->ResizeRenderTargetWithRotation(
{geometry.left, geometry.top, width, height}, rotation_degree_);
tizen_view_->ResizeWithRotation({geometry.left, geometry.top, width, height},
rotation_degree_);

// Window position does not change on rotation regardless of its orientation.
SendWindowMetrics(geometry.left, geometry.top, width, height, 0.0);
Expand Down Expand Up @@ -252,7 +268,14 @@ void FlutterTizenView::OnCommit(const std::string& str) {
}

void FlutterTizenView::SendInitialGeometry() {
OnRotate(window_->GetRotation());
if (tizen_view_->GetType() == TizenViewType::kWindow) {
auto* window = reinterpret_cast<TizenWindow*>(tizen_view_.get());
OnRotate(window->GetRotation());
} else {
TizenGeometry geometry = tizen_view_->GetGeometry();
SendWindowMetrics(geometry.left, geometry.top, geometry.width,
geometry.height, 0.0);
}
}

void FlutterTizenView::SendWindowMetrics(int32_t left,
Expand All @@ -268,7 +291,7 @@ void FlutterTizenView::SendWindowMetrics(int32_t left,
#ifdef TV_PROFILE
double dpi = 72.0;
#else
double dpi = static_cast<double>(window_->GetDpi());
double dpi = static_cast<double>(tizen_view_->GetDpi());
#endif
double scale_factor = dpi / 90.0 * kProfileFactor;
computed_pixel_ratio = std::max(scale_factor, 1.0);
Expand All @@ -288,7 +311,7 @@ void FlutterTizenView::SendFlutterPointerEvent(
size_t timestamp,
FlutterPointerDeviceKind device_kind,
int device_id) {
TizenWindow::Geometry geometry = window_->GetWindowGeometry();
TizenGeometry geometry = tizen_view_->GetGeometry();
double new_x = x, new_y = y;

if (rotation_degree_ == 90) {
Expand All @@ -305,8 +328,8 @@ void FlutterTizenView::SendFlutterPointerEvent(
FlutterPointerEvent event = {};
event.struct_size = sizeof(event);
event.phase = phase;
event.x = new_x;
event.y = new_y;
event.x = new_x - geometry.left;
event.y = new_y - geometry.top;
if (delta_x != 0 || delta_y != 0) {
event.signal_kind = kFlutterPointerSignalKindScroll;
}
Expand Down
9 changes: 4 additions & 5 deletions shell/platform/tizen/flutter_tizen_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
#include "flutter/shell/platform/tizen/channels/text_input_channel.h"
#include "flutter/shell/platform/tizen/channels/window_channel.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/tizen_window.h"

namespace flutter {

class FlutterTizenView {
public:
FlutterTizenView(std::unique_ptr<TizenWindow> window);
FlutterTizenView(std::unique_ptr<TizenViewBase> tizen_view);

~FlutterTizenView();

Expand All @@ -30,7 +29,7 @@ class FlutterTizenView {

FlutterTizenEngine* engine() { return engine_.get(); }

TizenWindow* window() { return window_.get(); }
TizenViewBase* tizen_view() { return tizen_view_.get(); }

// Creates rendering surface for Flutter engine to draw into.
// Should be called before calling FlutterEngineRun using this view.
Expand Down Expand Up @@ -126,8 +125,8 @@ class FlutterTizenView {
// The engine associated with this view.
std::unique_ptr<FlutterTizenEngine> engine_;

// The window associated with this view.
std::unique_ptr<TizenWindow> window_;
// The platform view associated with this Flutter view.
std::unique_ptr<TizenViewBase> tizen_view_;

// The plugin registrar managing internal plugins.
std::unique_ptr<PluginRegistrar> internal_plugin_registrar_;
Expand Down
Loading