diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 0100b97c15338..1951c6835a056 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -190,6 +190,7 @@ template("embedder") { sources += [ "flutter_tizen_elementary.cc", "tizen_renderer_evas_gl.cc", + "tizen_view_elementary.cc", "tizen_window_elementary.cc", ] diff --git a/shell/platform/tizen/channels/window_channel.cc b/shell/platform/tizen/channels/window_channel.cc index b7e246cb06946..1fec67ff07d26 100644 --- a/shell/platform/tizen/channels/window_channel.cc +++ b/shell/platform/tizen/channels/window_channel.cc @@ -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); @@ -57,9 +57,9 @@ void WindowChannel::HandleMethodCall( EncodableValueHolder width(arguments, "width"); EncodableValueHolder 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, @@ -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); diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 2f58bc48074a1..6d3beb3a4f1c5 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -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(tizen_view); + return window->GetWindowHandle(); + } + return nullptr; } void FlutterDesktopPluginRegistrarEnableInputBlocking( diff --git a/shell/platform/tizen/flutter_tizen_ecore.cc b/shell/platform/tizen/flutter_tizen_ecore.cc index f6dc7bad22a59..87ade651f9396 100644 --- a/shell/platform/tizen/flutter_tizen_ecore.cc +++ b/shell/platform/tizen/flutter_tizen_ecore.cc @@ -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 { @@ -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 window = std::make_unique( @@ -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!"; +} diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 29fbb3b1abb1c..dcf9174a790d4 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -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 { @@ -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 window = std::make_unique( @@ -52,3 +50,48 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( return HandleForView(view.release()); } + +FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( + const FlutterDesktopViewProperties& view_properties, + FlutterDesktopEngineRef engine, + void* parent) { + std::unique_ptr tizen_view = + std::make_unique( + view_properties.width, view_properties.height, + static_cast(parent)); + + auto view = + std::make_unique(std::move(tizen_view)); + + // Take ownership of the engine, starting it if necessary. + view->SetEngine( + std::unique_ptr(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(view_ref); + if (view->tizen_view()->GetType() == flutter::TizenViewType::kView) { + auto* tizen_view = + reinterpret_cast(view->tizen_view()); + return tizen_view->GetRenderTargetContainer(); + } + return nullptr; +} + +void FlutterDesktopViewResize(FlutterDesktopViewRef view_ref, + int32_t width, + int32_t height) { + auto* view = reinterpret_cast(view_ref); + flutter::TizenGeometry view_geometry = {0, 0, width, height}; + view->tizen_view()->OnGeometryChanged(view_geometry); +} diff --git a/shell/platform/tizen/flutter_tizen_engine.cc b/shell/platform/tizen/flutter_tizen_engine.cc index d28a5b5549a96..7856f9303ec30 100644 --- a/shell/platform/tizen/flutter_tizen_engine.cc +++ b/shell/platform/tizen/flutter_tizen_engine.cc @@ -536,8 +536,7 @@ void FlutterTizenEngine::OnUpdateSemanticsCustomActions( bridge->GetFlutterPlatformNodeDelegateFromID(0); std::shared_ptr 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); diff --git a/shell/platform/tizen/flutter_tizen_view.cc b/shell/platform/tizen/flutter_tizen_view.cc index 13dac43bfa2f4..5d65cf1ef0478 100644 --- a/shell/platform/tizen/flutter_tizen_view.cc +++ b/shell/platform/tizen/flutter_tizen_view.cc @@ -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 kBindableSystemKeys = { namespace flutter { -FlutterTizenView::FlutterTizenView(std::unique_ptr window) - : window_(std::move(window)) { - window_->SetView(this); - window_->BindKeys(kBindableSystemKeys); +FlutterTizenView::FlutterTizenView(std::unique_ptr tizen_view) + : tizen_view_(std::move(tizen_view)) { + tizen_view_->SetView(this); + tizen_view_->BindKeys(kBindableSystemKeys); } FlutterTizenView::~FlutterTizenView() {} @@ -57,19 +59,34 @@ void FlutterTizenView::SetEngine(std::unique_ptr engine) { // Set up window dependent channels. BinaryMessenger* messenger = internal_plugin_registrar_->messenger(); - platform_channel_ = - std::make_unique(messenger, window_.get()); - window_channel_ = std::make_unique(messenger, window_.get()); + + if (tizen_view_->GetType() == TizenViewType::kWindow) { + auto* window = reinterpret_cast(tizen_view_.get()); + platform_channel_ = std::make_unique(messenger, window); + window_channel_ = std::make_unique(messenger, window); + } else { + platform_channel_ = std::make_unique(messenger, nullptr); + window_channel_ = std::make_unique(messenger, nullptr); + } + text_input_channel_ = std::make_unique( - 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(tizen_view_.get()); + engine_->renderer()->CreateSurface(window->GetRenderTarget(), + window->GetRenderTargetDisplay(), + geometry.width, geometry.height); + } else { + auto* tizen_view = reinterpret_cast(tizen_view_.get()); + engine_->renderer()->CreateSurface(tizen_view->GetRenderTarget(), nullptr, + geometry.width, geometry.height); + } } } @@ -111,8 +128,7 @@ 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); } @@ -120,7 +136,7 @@ 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); @@ -254,7 +270,14 @@ void FlutterTizenView::OnCommit(const std::string& str) { } void FlutterTizenView::SendInitialGeometry() { - OnRotate(window_->GetRotation()); + if (tizen_view_->GetType() == TizenViewType::kWindow) { + auto* window = reinterpret_cast(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, @@ -270,7 +293,7 @@ void FlutterTizenView::SendWindowMetrics(int32_t left, #ifdef TV_PROFILE double dpi = 72.0; #else - double dpi = static_cast(window_->GetDpi()); + double dpi = static_cast(tizen_view_->GetDpi()); #endif double scale_factor = dpi / 90.0 * kProfileFactor; computed_pixel_ratio = std::max(scale_factor, 1.0); @@ -290,7 +313,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) { @@ -307,8 +330,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; } diff --git a/shell/platform/tizen/flutter_tizen_view.h b/shell/platform/tizen/flutter_tizen_view.h index f31b597c85d3f..790171455d599 100644 --- a/shell/platform/tizen/flutter_tizen_view.h +++ b/shell/platform/tizen/flutter_tizen_view.h @@ -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 window); + FlutterTizenView(std::unique_ptr tizen_view); ~FlutterTizenView(); @@ -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. @@ -126,8 +125,8 @@ class FlutterTizenView { // The engine associated with this view. std::unique_ptr engine_; - // The window associated with this view. - std::unique_ptr window_; + // The platform view associated with this Flutter view. + std::unique_ptr tizen_view_; // The plugin registrar managing internal plugins. std::unique_ptr internal_plugin_registrar_; diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index aeba4ec9e42b9..051ae3bd6d765 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -43,6 +43,14 @@ typedef struct { bool top_level; } FlutterDesktopWindowProperties; +// Properties for configuring the initial settings of a Flutter view. +typedef struct { + // The width of the view, or the maximum width if the value is zero. + int32_t width; + // The height of the view, or the maximum height if the value is zero. + int32_t height; +} FlutterDesktopViewProperties; + // Properties for configuring a Flutter engine instance. typedef struct { // The path to the flutter_assets folder for the application to be run. @@ -135,6 +143,28 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( const FlutterDesktopWindowProperties& window_properties, FlutterDesktopEngineRef engine); +// Creates a view that hosts and displays the given engine instance. +// +// The type of parent should be Evas_Object*, Cast Evas_Object* to void*. +// @warning This API is a work-in-progress and may change. +FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( + const FlutterDesktopViewProperties& view_properties, + FlutterDesktopEngineRef engine, + void* parent); + +// Returns a handle to evas object that the FlutterView is drawn to. +// +// Cast the returned void* to Evas_Object*. +// @warning This API is a work-in-progress and may change. +FLUTTER_EXPORT void* FlutterDesktopViewGetEvasObject( + FlutterDesktopViewRef view); + +// Resize the FlutterView. +// @warning This API is a work-in-progress and may change. +FLUTTER_EXPORT void FlutterDesktopViewResize(FlutterDesktopViewRef view, + int32_t width, + int32_t height); + // ========== Plugin Registrar (extensions) ========== // Returns the window associated with this registrar's engine instance. diff --git a/shell/platform/tizen/tizen_renderer_evas_gl.cc b/shell/platform/tizen/tizen_renderer_evas_gl.cc index 1e453dd9c7412..ae94366454e83 100644 --- a/shell/platform/tizen/tizen_renderer_evas_gl.cc +++ b/shell/platform/tizen/tizen_renderer_evas_gl.cc @@ -58,7 +58,7 @@ bool TizenRendererEvasGL::CreateSurface(void* render_target, Evas_Native_Surface native_surface; evas_gl_native_surface_get(evas_gl_, gl_surface_, &native_surface); - image_ = static_cast(render_target_display); + image_ = static_cast(render_target); evas_object_image_native_surface_set(image_, &native_surface); evas_object_image_pixels_get_callback_set( diff --git a/shell/platform/tizen/tizen_view.h b/shell/platform/tizen/tizen_view.h new file mode 100644 index 0000000000000..6fb8696ea2dda --- /dev/null +++ b/shell/platform/tizen/tizen_view.h @@ -0,0 +1,35 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_TIZEN_VIEW_H_ +#define EMBEDDER_TIZEN_VIEW_H_ + +#include + +#include "flutter/shell/platform/tizen/tizen_view_base.h" + +namespace flutter { + +class FlutterTizenView; + +class TizenView : public TizenViewBase { + public: + TizenView() = default; + virtual ~TizenView() = default; + + virtual void* GetRenderTargetContainer() = 0; + + TizenViewType GetType() override { return TizenViewType::kView; }; + + 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; +}; + +} // namespace flutter + +#endif // EMBEDDER_TIZEN_VIEW_H_ diff --git a/shell/platform/tizen/tizen_view_base.h b/shell/platform/tizen/tizen_view_base.h new file mode 100644 index 0000000000000..e480db982897e --- /dev/null +++ b/shell/platform/tizen/tizen_view_base.h @@ -0,0 +1,74 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_TIZEN_VIEW_BASE_H_ +#define EMBEDDER_TIZEN_VIEW_BASE_H_ + +#include +#include +#include +#include + +#include "flutter/shell/platform/tizen/tizen_input_method_context.h" + +namespace flutter { + +class FlutterTizenView; + +struct TizenGeometry { + int32_t left = 0, top = 0, width = 0, height = 0; +}; + +enum class TizenViewType { kView, kWindow }; + +class TizenViewBase { + public: + TizenViewBase() = default; + virtual ~TizenViewBase() = default; + + // Returns a pointer to the platform object that rendering can be bound to + // by the rendering backend. + virtual void* GetRenderTarget() = 0; + + virtual uintptr_t GetWindowId() = 0; + + // Returns the geometry of the view. + virtual TizenGeometry GetGeometry() = 0; + + // Set the geometry of the view. + virtual void SetGeometry(TizenGeometry geometry) = 0; + + // Returns the dpi of the screen. + virtual int32_t GetDpi() = 0; + + // Sets the delegate used to communicate state changes from render target to + // view such as key presses, mouse position updates etc. + void SetView(FlutterTizenView* view) { view_ = view; } + + virtual void BindKeys(const std::vector& keys) = 0; + + virtual void ResizeWithRotation(TizenGeometry geometry, int32_t degree) = 0; + + // FIXME + // This is a temporary implementation that is only used by the window channel. + virtual void OnGeometryChanged(TizenGeometry geometry) = 0; + + virtual void Show() = 0; + + virtual TizenViewType GetType() = 0; + + TizenInputMethodContext* input_method_context() { + return input_method_context_.get(); + } + + protected: + FlutterTizenView* view_ = nullptr; + + // The Tizen input method context. nullptr if not set. + std::unique_ptr input_method_context_; +}; + +} // namespace flutter + +#endif // EMBEDDER_TIZEN_VIEW_BASE_H_ diff --git a/shell/platform/tizen/tizen_view_elementary.cc b/shell/platform/tizen/tizen_view_elementary.cc new file mode 100644 index 0000000000000..bf2707b174ed4 --- /dev/null +++ b/shell/platform/tizen/tizen_view_elementary.cc @@ -0,0 +1,354 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tizen_view_elementary.h" + +#include +#include + +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/logger.h" + +namespace { + +static const int kScrollDirectionVertical = 0; +static const int kScrollDirectionHorizontal = 1; +static const int kScrollOffsetMultiplier = 20; + +uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) { + uint32_t modifiers = 0; + if (evas_key_modifier_is_set(evas_modifier, "Control")) { + modifiers |= ECORE_EVENT_MODIFIER_CTRL; + } + if (evas_key_modifier_is_set(evas_modifier, "Alt")) { + modifiers |= ECORE_EVENT_MODIFIER_ALT; + } + if (evas_key_modifier_is_set(evas_modifier, "Shift")) { + modifiers |= ECORE_EVENT_MODIFIER_SHIFT; + } + return modifiers; +} + +void EvasObjectResize(Evas_Object* object, int32_t width, int32_t height) { + evas_object_resize(object, width, height); + evas_object_size_hint_min_set(object, width, height); + evas_object_size_hint_max_set(object, width, height); +} + +} // namespace + +namespace flutter { + +TizenViewElementary::TizenViewElementary(int32_t width, + int32_t height, + Evas_Object* parent) + : TizenView(width, height), parent_(parent) { + if (!CreateView()) { + FT_LOG(Error) << "Failed to create a platform view."; + return; + } + + RegisterEventHandlers(); + PrepareInputMethod(); + Show(); +} + +TizenViewElementary::~TizenViewElementary() { + UnregisterEventHandlers(); + DestroyView(); +} + +bool TizenViewElementary::CreateView() { + elm_config_accel_preference_set("hw:opengl"); + + int32_t parent_width, parent_height; + evas_object_geometry_get(parent_, nullptr, nullptr, &parent_width, + &parent_height); + + if (initial_width_ == 0) { + initial_width_ = parent_width; + } + if (initial_height_ == 0) { + initial_height_ = parent_height; + } + + container_ = elm_table_add(parent_); + if (!container_) { + FT_LOG(Error) << "Failed to create an Evas object container."; + return false; + } + evas_object_size_hint_weight_set(container_, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + image_ = evas_object_image_filled_add(evas_object_evas_get(container_)); + if (!image_) { + FT_LOG(Error) << "Failed to create an Evas object image."; + return false; + } + evas_object_size_hint_align_set(image_, EVAS_HINT_FILL, EVAS_HINT_FILL); + EvasObjectResize(image_, initial_width_, initial_height_); + evas_object_image_size_set(image_, initial_width_, initial_height_); + evas_object_image_alpha_set(image_, EINA_TRUE); + elm_table_pack(container_, image_, 0, 0, 1, 1); + + // FIXME: Button widgets can receive both mouse events and key events. But the + // button widget is temporary. It should be changed to the appropriate object + // that can be used as event layer. + event_layer_ = elm_button_add(container_); + if (!event_layer_) { + FT_LOG(Error) << "Failed to create an event layer."; + return false; + } + evas_object_size_hint_weight_set(event_layer_, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(event_layer_, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_style_set(event_layer_, "transparent"); + evas_object_color_set(event_layer_, 0, 0, 0, 0); + elm_table_pack(container_, event_layer_, 0, 0, 1, 1); + + return true; +} + +void TizenViewElementary::DestroyView() { + evas_object_del(event_layer_); + evas_object_del(image_); + evas_object_del(container_); +} + +void TizenViewElementary::RegisterEventHandlers() { + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* mouse_event = + reinterpret_cast(event_info); + self->view_->OnPointerDown( + mouse_event->canvas.x, mouse_event->canvas.y, + mouse_event->timestamp, kFlutterPointerDeviceKindTouch, + mouse_event->button); + } + } + }; + evas_object_event_callback_add( + event_layer_, EVAS_CALLBACK_MOUSE_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN], this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* mouse_event = reinterpret_cast(event_info); + if (self->scroll_hold_) { + elm_object_scroll_hold_pop(self->event_layer_); + self->scroll_hold_ = false; + } + self->view_->OnPointerUp(mouse_event->canvas.x, mouse_event->canvas.y, + mouse_event->timestamp, + kFlutterPointerDeviceKindTouch, + mouse_event->button); + } + } + }; + evas_object_event_callback_add(event_layer_, EVAS_CALLBACK_MOUSE_UP, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP], + this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* mouse_event = + reinterpret_cast(event_info); + mouse_event->event_flags = Evas_Event_Flags( + mouse_event->event_flags | EVAS_EVENT_FLAG_ON_HOLD); + if (!self->scroll_hold_) { + elm_object_scroll_hold_push(self->event_layer_); + self->scroll_hold_ = true; + } + self->view_->OnPointerMove( + mouse_event->cur.canvas.x, mouse_event->cur.canvas.y, + mouse_event->timestamp, kFlutterPointerDeviceKindTouch, + mouse_event->buttons); + } + } + }; + evas_object_event_callback_add( + event_layer_, EVAS_CALLBACK_MOUSE_MOVE, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE], this); + + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* wheel_event = + reinterpret_cast(event_info); + double delta_x = 0.0; + double delta_y = 0.0; + + if (wheel_event->direction == kScrollDirectionVertical) { + delta_y += wheel_event->z; + } else if (wheel_event->direction == kScrollDirectionHorizontal) { + delta_x += wheel_event->z; + } + + self->view_->OnScroll(wheel_event->x, wheel_event->y, delta_x, delta_y, + kScrollOffsetMultiplier, wheel_event->timestamp, + kFlutterPointerDeviceKindTouch, 0); + } + } + }; + evas_object_event_callback_add( + event_layer_, EVAS_CALLBACK_MOUSE_WHEEL, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL], this); + + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN] = [](void* data, Evas* evas, + Evas_Object* object, + void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* key_event = reinterpret_cast(event_info); + int handled = false; + key_event->event_flags = + Evas_Event_Flags(key_event->event_flags | EVAS_EVENT_FLAG_ON_HOLD); + if (self->input_method_context_->IsInputPanelShown()) { + handled = + self->input_method_context_->HandleEvasEventKeyDown(key_event); + } + if (!handled) { + self->view_->OnKey( + key_event->key, key_event->string, key_event->compose, + EvasModifierToEcoreEventModifiers(key_event->modifiers), + key_event->keycode, true); + } + } + } + }; + evas_object_event_callback_add(event_layer_, EVAS_CALLBACK_KEY_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN], + this); + + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP] = + [](void* data, Evas* evas, Evas_Object* object, void* event_info) { + auto* self = reinterpret_cast(data); + if (self->view_) { + if (self->event_layer_ == object) { + auto* key_event = reinterpret_cast(event_info); + int handled = false; + key_event->event_flags = Evas_Event_Flags(key_event->event_flags | + EVAS_EVENT_FLAG_ON_HOLD); + if (self->input_method_context_->IsInputPanelShown()) { + handled = + self->input_method_context_->HandleEvasEventKeyUp(key_event); + } + if (!handled) { + self->view_->OnKey( + key_event->key, key_event->string, key_event->compose, + EvasModifierToEcoreEventModifiers(key_event->modifiers), + key_event->keycode, false); + } + } + } + }; + evas_object_event_callback_add(event_layer_, EVAS_CALLBACK_KEY_UP, + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP], + this); +} + +void TizenViewElementary::UnregisterEventHandlers() { + evas_object_event_callback_del( + image_, EVAS_CALLBACK_MOUSE_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_DOWN]); + evas_object_event_callback_del( + image_, EVAS_CALLBACK_MOUSE_UP, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_UP]); + evas_object_event_callback_del( + image_, EVAS_CALLBACK_MOUSE_MOVE, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_MOVE]); + evas_object_event_callback_del( + image_, EVAS_CALLBACK_MOUSE_WHEEL, + evas_object_callbacks_[EVAS_CALLBACK_MOUSE_WHEEL]); + evas_object_event_callback_del( + container_, EVAS_CALLBACK_KEY_DOWN, + evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN]); + evas_object_event_callback_del(container_, EVAS_CALLBACK_KEY_UP, + evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]); +} + +TizenGeometry TizenViewElementary::GetGeometry() { + TizenGeometry result; + evas_object_geometry_get(image_, &result.left, &result.top, &result.width, + &result.height); + return result; +} + +void TizenViewElementary::SetGeometry(TizenGeometry geometry) { + EvasObjectResize(image_, geometry.width, geometry.height); + evas_object_move(image_, geometry.left, geometry.top); +} + +int32_t TizenViewElementary::GetDpi() { + Ecore_Evas* ecore_evas = + ecore_evas_ecore_evas_get(evas_object_evas_get(image_)); + int32_t xdpi, ydpi; + ecore_evas_screen_dpi_get(ecore_evas, &xdpi, &ydpi); + return xdpi; +} + +uintptr_t TizenViewElementary::GetWindowId() { + return ecore_evas_window_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(image_))); +} + +void TizenViewElementary::ResizeWithRotation(TizenGeometry geometry, + int32_t angle) { + TizenRendererEvasGL* renderer_evas_gl = + reinterpret_cast(view_->engine()->renderer()); + renderer_evas_gl->ResizeSurface(geometry.width, geometry.height); +} + +void TizenViewElementary::BindKeys(const std::vector& keys) { + Evas_Object* elm_win = static_cast(ecore_evas_data_get( + ecore_evas_ecore_evas_get(evas_object_evas_get(parent_)), "elm_win")); + if (elm_win) { + for (const std::string& key : keys) { + eext_win_keygrab_set(elm_win, key.c_str()); + } + } +} + +void TizenViewElementary::Show() { + evas_object_show(container_); + evas_object_show(image_); + evas_object_show(event_layer_); +} + +void TizenViewElementary::OnGeometryChanged(TizenGeometry geometry) { + SetGeometry(geometry); + view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); +} + +void TizenViewElementary::PrepareInputMethod() { + input_method_context_ = + std::make_unique(GetWindowId()); + + // Set input method callbacks. + input_method_context_->SetOnPreeditStart( + [this]() { view_->OnComposeBegin(); }); + input_method_context_->SetOnPreeditChanged( + [this](std::string str, int cursor_pos) { + view_->OnComposeChange(str, cursor_pos); + }); + input_method_context_->SetOnPreeditEnd([this]() { view_->OnComposeEnd(); }); + input_method_context_->SetOnCommit( + [this](std::string str) { view_->OnCommit(str); }); +} + +} // namespace flutter diff --git a/shell/platform/tizen/tizen_view_elementary.h b/shell/platform/tizen/tizen_view_elementary.h new file mode 100644 index 0000000000000..5262f7511510d --- /dev/null +++ b/shell/platform/tizen/tizen_view_elementary.h @@ -0,0 +1,72 @@ +// Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EMBEDDER_TIZEN_VIEW_ELEMENTARY_H_ +#define EMBEDDER_TIZEN_VIEW_ELEMENTARY_H_ + +#define EFL_BETA_API_SUPPORT +#include +#include + +#include +#include +#include +#include + +#include "flutter/shell/platform/tizen/tizen_view.h" + +namespace flutter { + +class TizenViewElementary : public TizenView { + public: + TizenViewElementary(int32_t width, int32_t height, Evas_Object* parent); + + ~TizenViewElementary(); + + TizenGeometry GetGeometry() override; + + void SetGeometry(TizenGeometry geometry) override; + + void* GetRenderTarget() override { return image_; } + + void* GetRenderTargetContainer() override { return container_; } + + int32_t GetDpi() override; + + uintptr_t GetWindowId() override; + + void ResizeWithRotation(TizenGeometry geometry, int32_t angle) override; + + void BindKeys(const std::vector& keys) override; + + void Show() override; + + void OnGeometryChanged(TizenGeometry geometry) override; + + private: + bool CreateView(); + + void DestroyView(); + + void RegisterEventHandlers(); + + void UnregisterEventHandlers(); + + void PrepareInputMethod(); + + Evas_Object* parent_ = nullptr; + Evas_Object* container_ = nullptr; + Evas_Object* image_ = nullptr; + Evas_Object* event_layer_ = nullptr; + + std::unordered_map + evas_object_callbacks_; + std::vector ecore_event_key_handlers_; + + bool scroll_hold_ = false; +}; + +} // namespace flutter + +#endif // EMBEDDER_TIZEN_VIEW_ELEMENTARY_H_ diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index a058e2684b71c..cd87a729e0be5 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -1,5 +1,4 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,70 +6,34 @@ #define EMBEDDER_TIZEN_WINDOW_H_ #include -#include #include -#include "flutter/shell/platform/tizen/tizen_input_method_context.h" +#include "flutter/shell/platform/tizen/tizen_view_base.h" namespace flutter { class FlutterTizenView; -class TizenWindow { +class TizenWindow : public TizenViewBase { public: - struct Geometry { - int32_t left = 0, top = 0, width = 0, height = 0; - }; - + TizenWindow() = default; virtual ~TizenWindow() = default; - // Sets the delegate used to communicate state changes from window to view - // such as key presses, mouse position updates etc. - void SetView(FlutterTizenView* view) { view_ = view; } - - // Returns the geometry of the current window. - virtual Geometry GetWindowGeometry() = 0; - - // Set the geometry of the current window. - virtual void SetWindowGeometry(Geometry geometry) = 0; - - // Returns the geometry of the display screen. - virtual Geometry GetScreenGeometry() = 0; - - // Returns a valid pointer the platform object that rendering can be bound to - // by rendering backend. - virtual void* GetRenderTarget() = 0; - - virtual void* GetRenderTargetDisplay() = 0; + virtual void* GetWindowHandle(); virtual int32_t GetRotation() = 0; - // Returns the dpi of the screen. - virtual int32_t GetDpi() = 0; - - virtual uintptr_t GetWindowId() = 0; + virtual void SetPreferredOrientations(const std::vector& rotations); - virtual void* GetWindowHandle() = 0; - - virtual void ResizeRenderTargetWithRotation(Geometry geometry, - int32_t degree) = 0; - - virtual void SetPreferredOrientations(const std::vector& rotations) = 0; - - virtual void BindKeys(const std::vector& keys) = 0; - - virtual void Show() = 0; + virtual void* GetRenderTargetDisplay() = 0; - // FIXME - // This is a temporary implementation that is only used by the window channel. - virtual void OnGeometryChanged(Geometry geometry) = 0; + // Returns the geometry of the display screen. + virtual TizenGeometry GetScreenGeometry() = 0; - TizenInputMethodContext* input_method_context() { - return input_method_context_.get(); - } + TizenViewType GetType() override { return TizenViewType::kWindow; }; protected: - explicit TizenWindow(Geometry geometry, + explicit TizenWindow(TizenGeometry geometry, bool transparent, bool focusable, bool top_level) @@ -79,15 +42,10 @@ class TizenWindow { focusable_(focusable), top_level_(top_level) {} - Geometry initial_geometry_ = {0, 0, 0, 0}; + TizenGeometry initial_geometry_ = {0, 0, 0, 0}; bool transparent_ = false; bool focusable_ = false; bool top_level_ = false; - - FlutterTizenView* view_ = nullptr; - - // The Tizen input method context. nullptr if not set. - std::unique_ptr input_method_context_; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.cc b/shell/platform/tizen/tizen_window_ecore_wl2.cc index e1aef82ca21b6..5b71816898716 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.cc +++ b/shell/platform/tizen/tizen_window_ecore_wl2.cc @@ -1,5 +1,4 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,7 +21,7 @@ static const int kScrollOffsetMultiplier = 20; namespace flutter { -TizenWindowEcoreWl2::TizenWindowEcoreWl2(Geometry geometry, +TizenWindowEcoreWl2::TizenWindowEcoreWl2(TizenGeometry geometry, bool transparent, bool focusable, bool top_level) @@ -198,7 +197,7 @@ void TizenWindowEcoreWl2::RegisterEventHandlers() { if (rotation_event->win == self->GetWindowId()) { int32_t degree = rotation_event->angle; self->view_->OnRotate(degree); - Geometry geometry = self->GetWindowGeometry(); + TizenGeometry geometry = self->GetGeometry(); ecore_wl2_window_rotation_change_done_send( self->ecore_wl2_window_, rotation_event->rotation, geometry.width, geometry.height); @@ -381,14 +380,14 @@ void TizenWindowEcoreWl2::DestroyWindow() { ecore_wl2_shutdown(); } -TizenWindow::Geometry TizenWindowEcoreWl2::GetWindowGeometry() { - Geometry result; +TizenGeometry TizenWindowEcoreWl2::GetGeometry() { + TizenGeometry result; ecore_wl2_window_geometry_get(ecore_wl2_window_, &result.left, &result.top, &result.width, &result.height); return result; } -void TizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { +void TizenWindowEcoreWl2::SetGeometry(TizenGeometry geometry) { ecore_wl2_window_geometry_set(ecore_wl2_window_, geometry.left, geometry.top, geometry.width, geometry.height); // FIXME: The changes set in `ecore_wl2_window_geometry_set` seems to apply @@ -397,8 +396,8 @@ void TizenWindowEcoreWl2::SetWindowGeometry(Geometry geometry) { ecore_wl2_window_position_set(ecore_wl2_window_, geometry.left, geometry.top); } -TizenWindow::Geometry TizenWindowEcoreWl2::GetScreenGeometry() { - Geometry result = {}; +TizenGeometry TizenWindowEcoreWl2::GetScreenGeometry() { + TizenGeometry result = {}; ecore_wl2_display_screen_size_get(ecore_wl2_display_, &result.width, &result.height); return result; @@ -421,8 +420,8 @@ uintptr_t TizenWindowEcoreWl2::GetWindowId() { return ecore_wl2_window_id_get(ecore_wl2_window_); } -void TizenWindowEcoreWl2::ResizeRenderTargetWithRotation(Geometry geometry, - int32_t angle) { +void TizenWindowEcoreWl2::ResizeWithRotation(TizenGeometry geometry, + int32_t angle) { ecore_wl2_egl_window_resize_with_rotation( ecore_wl2_egl_window_, geometry.left, geometry.top, geometry.width, geometry.height, angle); @@ -445,10 +444,10 @@ void TizenWindowEcoreWl2::Show() { ecore_wl2_window_show(ecore_wl2_window_); } -void TizenWindowEcoreWl2::OnGeometryChanged(Geometry geometry) { +void TizenWindowEcoreWl2::OnGeometryChanged(TizenGeometry geometry) { // This implementation mimics the situation in which the handler of // ECORE_WL2_EVENT_WINDOW_CONFIGURE is called. - SetWindowGeometry(geometry); + SetGeometry(geometry); view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); } diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index 8b4f88fe10dc6..8d8d00745014d 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -1,33 +1,36 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ #define EMBEDDER_TIZEN_WINDOW_ECORE_WL2_H_ -#include "flutter/shell/platform/tizen/tizen_window.h" - #define EFL_BETA_API_SUPPORT #include #include +#include +#include +#include + +#include "flutter/shell/platform/tizen/tizen_window.h" + namespace flutter { class TizenWindowEcoreWl2 : public TizenWindow { public: - TizenWindowEcoreWl2(Geometry geometry, + TizenWindowEcoreWl2(TizenGeometry geometry, bool transparent, bool focusable, bool top_level); ~TizenWindowEcoreWl2(); - Geometry GetWindowGeometry() override; + TizenGeometry GetGeometry() override; - void SetWindowGeometry(Geometry geometry) override; + void SetGeometry(TizenGeometry geometry) override; - Geometry GetScreenGeometry() override; + TizenGeometry GetScreenGeometry() override; void* GetRenderTarget() override { return ecore_wl2_egl_window_; } @@ -41,8 +44,7 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetWindowHandle() override { return ecore_wl2_window_; } - void ResizeRenderTargetWithRotation(Geometry geometry, - int32_t angle) override; + void ResizeWithRotation(TizenGeometry geometry, int32_t angle) override; void SetPreferredOrientations(const std::vector& rotations) override; @@ -50,7 +52,7 @@ class TizenWindowEcoreWl2 : public TizenWindow { void Show() override; - void OnGeometryChanged(Geometry geometry) override; + void OnGeometryChanged(TizenGeometry geometry) override; private: bool CreateWindow(); diff --git a/shell/platform/tizen/tizen_window_elementary.cc b/shell/platform/tizen/tizen_window_elementary.cc index c3e3341befb66..21397b4ef1a60 100644 --- a/shell/platform/tizen/tizen_window_elementary.cc +++ b/shell/platform/tizen/tizen_window_elementary.cc @@ -1,16 +1,15 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "tizen_window_elementary.h" -#include "flutter/shell/platform/tizen/flutter_tizen_view.h" -#include "flutter/shell/platform/tizen/logger.h" - #include #include +#include "flutter/shell/platform/tizen/flutter_tizen_view.h" +#include "flutter/shell/platform/tizen/logger.h" + namespace { static const int kScrollDirectionVertical = 0; @@ -35,7 +34,7 @@ uint32_t EvasModifierToEcoreEventModifiers(const Evas_Modifier* evas_modifier) { namespace flutter { -TizenWindowElementary::TizenWindowElementary(Geometry geometry, +TizenWindowElementary::TizenWindowElementary(TizenGeometry geometry, bool transparent, bool focusable, bool top_level) @@ -305,16 +304,16 @@ void TizenWindowElementary::UnregisterEventHandlers() { evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]); } -TizenWindow::Geometry TizenWindowElementary::GetWindowGeometry() { +TizenGeometry TizenWindowElementary::GetGeometry() { // FIXME : evas_object_geometry_get() and ecore_wl2_window_geometry_get() are // not equivalent. - Geometry result; + TizenGeometry result; evas_object_geometry_get(elm_win_, &result.left, &result.top, &result.width, &result.height); return result; } -void TizenWindowElementary::SetWindowGeometry(Geometry geometry) { +void TizenWindowElementary::SetGeometry(TizenGeometry geometry) { evas_object_resize(elm_win_, geometry.width, geometry.height); evas_object_move(elm_win_, geometry.left, geometry.top); @@ -322,8 +321,8 @@ void TizenWindowElementary::SetWindowGeometry(Geometry geometry) { evas_object_move(image_, geometry.left, geometry.top); } -TizenWindow::Geometry TizenWindowElementary::GetScreenGeometry() { - Geometry result; +TizenGeometry TizenWindowElementary::GetScreenGeometry() { + TizenGeometry result; Ecore_Evas* ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_)); ecore_evas_screen_geometry_get(ecore_evas, nullptr, nullptr, &result.width, @@ -344,12 +343,11 @@ int32_t TizenWindowElementary::GetDpi() { } uintptr_t TizenWindowElementary::GetWindowId() { - return ecore_evas_window_get( - ecore_evas_ecore_evas_get(evas_object_evas_get(elm_win_))); + return elm_win_window_id_get(elm_win_); } -void TizenWindowElementary::ResizeRenderTargetWithRotation(Geometry geometry, - int32_t angle) { +void TizenWindowElementary::ResizeWithRotation(TizenGeometry geometry, + int32_t angle) { TizenRendererEvasGL* renderer_evas_gl = reinterpret_cast(view_->engine()->renderer()); renderer_evas_gl->ResizeSurface(geometry.width, geometry.height); @@ -373,8 +371,8 @@ void TizenWindowElementary::Show() { evas_object_show(elm_win_); } -void TizenWindowElementary::OnGeometryChanged(Geometry geometry) { - SetWindowGeometry(geometry); +void TizenWindowElementary::OnGeometryChanged(TizenGeometry geometry) { + SetGeometry(geometry); view_->OnResize(geometry.left, geometry.top, geometry.width, geometry.height); } diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index ac3fa9fcb4aeb..16478e82a966b 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -1,37 +1,39 @@ // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EMBEDDER_TIZEN_WINDOW_ELEMENTARY_H_ #define EMBEDDER_TIZEN_WINDOW_ELEMENTARY_H_ -#include "flutter/shell/platform/tizen/tizen_window.h" - #include +#include +#include #include +#include + +#include "flutter/shell/platform/tizen/tizen_window.h" namespace flutter { class TizenWindowElementary : public TizenWindow { public: - TizenWindowElementary(Geometry geometry, + TizenWindowElementary(TizenGeometry geometry, bool transparent, bool focusable, bool top_level); ~TizenWindowElementary(); - Geometry GetWindowGeometry() override; + TizenGeometry GetGeometry() override; - void SetWindowGeometry(Geometry geometry) override; + void SetGeometry(TizenGeometry geometry) override; - Geometry GetScreenGeometry() override; + TizenGeometry GetScreenGeometry() override; - void* GetRenderTarget() override { return elm_win_; } + void* GetRenderTarget() override { return image_; } - void* GetRenderTargetDisplay() override { return image_; } + void* GetRenderTargetDisplay() override { return nullptr; } int32_t GetRotation() override; @@ -41,8 +43,7 @@ class TizenWindowElementary : public TizenWindow { void* GetWindowHandle() override { return elm_win_; } - void ResizeRenderTargetWithRotation(Geometry geometry, - int32_t angle) override; + void ResizeWithRotation(TizenGeometry geometry, int32_t angle) override; void SetPreferredOrientations(const std::vector& rotations) override; @@ -50,7 +51,7 @@ class TizenWindowElementary : public TizenWindow { void Show() override; - void OnGeometryChanged(Geometry geometry) override; + void OnGeometryChanged(TizenGeometry geometry) override; private: bool CreateWindow();