From 0948a0817d4815075dce97fd8b1219448f5b213f Mon Sep 17 00:00:00 2001 From: Swanseo0 <98388769+Swanseo0@users.noreply.github.com> Date: Tue, 16 Aug 2022 17:06:25 +1100 Subject: [PATCH] Add FlutterDesktopViewGetNativeHandle (#314) Makes all tizen view types be able to get target container handle. Signed-off-by: swan.seo --- shell/platform/tizen/flutter_tizen.cc | 16 +++++++++------- shell/platform/tizen/flutter_tizen_elementary.cc | 10 ---------- shell/platform/tizen/public/flutter_tizen.h | 16 ++++++++-------- shell/platform/tizen/tizen_view.h | 2 -- shell/platform/tizen/tizen_view_base.h | 2 ++ shell/platform/tizen/tizen_view_elementary.h | 2 +- shell/platform/tizen/tizen_window.h | 2 -- shell/platform/tizen/tizen_window_ecore_wl2.h | 4 ++-- shell/platform/tizen/tizen_window_elementary.h | 4 ++-- 9 files changed, 24 insertions(+), 34 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index c1778f79df54a..af6266c456b1b 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -82,14 +82,9 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) { delete engine; } -void* FlutterDesktopPluginRegistrarGetNativeWindow( +FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView( FlutterDesktopPluginRegistrarRef registrar) { - 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; + return HandleForView(registrar->engine->view()); } void FlutterDesktopPluginRegistrarEnableInputBlocking( @@ -233,6 +228,13 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( return HandleForView(view.release()); } +void* FlutterDesktopViewGetNativeHandle(FlutterDesktopViewRef view_ref) { + flutter::FlutterTizenView* view = ViewFromHandle(view_ref); + auto* tizen_view = + reinterpret_cast(view->tizen_view()); + return tizen_view->GetNativeHandle(); +} + void FlutterDesktopViewResize(FlutterDesktopViewRef view, int32_t width, int32_t height) { diff --git a/shell/platform/tizen/flutter_tizen_elementary.cc b/shell/platform/tizen/flutter_tizen_elementary.cc index 187e1e7a4c665..9123930233164 100644 --- a/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/shell/platform/tizen/flutter_tizen_elementary.cc @@ -47,13 +47,3 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( 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; -} diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index a00138439e5ba..53ae6d3faa714 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -167,11 +167,14 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( // @warning This API is a work-in-progress and may change. FLUTTER_EXPORT void FlutterDesktopViewDestroy(FlutterDesktopViewRef view); -// Returns a handle to evas object that the FlutterView is drawn to. +// Returns a native UI toolkit handle for manipulation in host application. // -// Cast the returned void* to Evas_Object*. +// Cast the returned void* +// - view elementary : to Evas_Object*. +// - window elementary : to Evas_Object* +// - window ecore wl2 : to Ecore_Wl2_Window* // @warning This API is a work-in-progress and may change. -FLUTTER_EXPORT void* FlutterDesktopViewGetEvasObject( +FLUTTER_EXPORT void* FlutterDesktopViewGetNativeHandle( FlutterDesktopViewRef view); // Resizes the view. @@ -182,11 +185,8 @@ FLUTTER_EXPORT void FlutterDesktopViewResize(FlutterDesktopViewRef view, // ========== Plugin Registrar (extensions) ========== -// Returns the window associated with this registrar's engine instance. -// -// If the app runs on a wearable device, cast void* to Evas_Object*, -// otherwise cast it to Ecore_Wl2_Window*. -FLUTTER_EXPORT void* FlutterDesktopPluginRegistrarGetNativeWindow( +// Returns the view associated with this registrar's engine instance. +FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView( FlutterDesktopPluginRegistrarRef registrar); #if defined(__cplusplus) diff --git a/shell/platform/tizen/tizen_view.h b/shell/platform/tizen/tizen_view.h index 6fb8696ea2dda..f39447c2edaff 100644 --- a/shell/platform/tizen/tizen_view.h +++ b/shell/platform/tizen/tizen_view.h @@ -18,8 +18,6 @@ class TizenView : public TizenViewBase { TizenView() = default; virtual ~TizenView() = default; - virtual void* GetRenderTargetContainer() = 0; - TizenViewType GetType() override { return TizenViewType::kView; }; protected: diff --git a/shell/platform/tizen/tizen_view_base.h b/shell/platform/tizen/tizen_view_base.h index 113121a6c7f68..3f3f6190ac6cb 100644 --- a/shell/platform/tizen/tizen_view_base.h +++ b/shell/platform/tizen/tizen_view_base.h @@ -30,6 +30,8 @@ class TizenViewBase { // by the rendering backend. virtual void* GetRenderTarget() = 0; + virtual void* GetNativeHandle() = 0; + virtual uintptr_t GetWindowId() = 0; // Returns the geometry of the view. diff --git a/shell/platform/tizen/tizen_view_elementary.h b/shell/platform/tizen/tizen_view_elementary.h index 74e58cb994313..5304d9b8c5dd4 100644 --- a/shell/platform/tizen/tizen_view_elementary.h +++ b/shell/platform/tizen/tizen_view_elementary.h @@ -30,7 +30,7 @@ class TizenViewElementary : public TizenView { void* GetRenderTarget() override { return image_; } - void* GetRenderTargetContainer() override { return container_; } + void* GetNativeHandle() override { return container_; } int32_t GetDpi() override; diff --git a/shell/platform/tizen/tizen_window.h b/shell/platform/tizen/tizen_window.h index 2b78edb3c1a7b..a78793f062b20 100644 --- a/shell/platform/tizen/tizen_window.h +++ b/shell/platform/tizen/tizen_window.h @@ -19,8 +19,6 @@ class TizenWindow : public TizenViewBase { TizenWindow() = default; virtual ~TizenWindow() = default; - virtual void* GetWindowHandle() = 0; - virtual int32_t GetRotation() = 0; virtual void SetPreferredOrientations(const std::vector& rotations) = 0; diff --git a/shell/platform/tizen/tizen_window_ecore_wl2.h b/shell/platform/tizen/tizen_window_ecore_wl2.h index ecf77a52fc8e7..7ad6c716e0ea1 100644 --- a/shell/platform/tizen/tizen_window_ecore_wl2.h +++ b/shell/platform/tizen/tizen_window_ecore_wl2.h @@ -36,14 +36,14 @@ class TizenWindowEcoreWl2 : public TizenWindow { void* GetRenderTargetDisplay() override { return wl2_display_; } + void* GetNativeHandle() override { return ecore_wl2_window_; } + int32_t GetRotation() override; int32_t GetDpi() override; uintptr_t GetWindowId() override; - void* GetWindowHandle() override { return ecore_wl2_window_; } - void SetPreferredOrientations(const std::vector& rotations) override; void BindKeys(const std::vector& keys) override; diff --git a/shell/platform/tizen/tizen_window_elementary.h b/shell/platform/tizen/tizen_window_elementary.h index ceb5f1fb05892..aabb02cf8935b 100644 --- a/shell/platform/tizen/tizen_window_elementary.h +++ b/shell/platform/tizen/tizen_window_elementary.h @@ -35,14 +35,14 @@ class TizenWindowElementary : public TizenWindow { void* GetRenderTargetDisplay() override { return nullptr; } + void* GetNativeHandle() override { return elm_win_; } + int32_t GetRotation() override; int32_t GetDpi() override; uintptr_t GetWindowId() override; - void* GetWindowHandle() override { return elm_win_; } - void SetPreferredOrientations(const std::vector& rotations) override; void BindKeys(const std::vector& keys) override;