-
Notifications
You must be signed in to change notification settings - Fork 17
Introduce TizenViewElementary #292
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
Changes from all commits
4b3c327
311e6b0
ca61f57
b3bb0d6
2e777e8
a1f8ba4
2c14b3a
c282815
7041b0e
0625e16
eaf8efd
0fa299f
08c9172
0e39447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
||
|
|
@@ -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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the type of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that makes sense. I think we can move
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the view also needs a bind to a special key. This has already been talked about in private chats. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can handle it in another PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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. however, it seems problematic for the view to modify the properties of the window. |
||
| } | ||
|
|
||
| FlutterTizenView::~FlutterTizenView() {} | ||
|
|
@@ -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); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -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; | ||
|
|
||
|
|
@@ -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); | ||
|
|
@@ -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, | ||
|
|
@@ -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); | ||
|
|
@@ -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) { | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree.
FlutterTizenViewis simply an abstraction layer for a Flutter view and it should not be considered as a wrapper ofTizenView.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 :)
There was a problem hiding this comment.
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
resizerather than simple property change, I think it is better to handle it withview->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.