Skip to content

Commit

Permalink
Add FlutterDesktopViewGetNativeHandle (#314)
Browse files Browse the repository at this point in the history
Makes all tizen view types be able to get target container handle.

Signed-off-by: swan.seo <[email protected]>
  • Loading branch information
Swanseo0 authored Aug 16, 2022
1 parent c60bdea commit 0948a08
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 34 deletions.
16 changes: 9 additions & 7 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<flutter::TizenWindow*>(tizen_view);
return window->GetWindowHandle();
}
return nullptr;
return HandleForView(registrar->engine->view());
}

void FlutterDesktopPluginRegistrarEnableInputBlocking(
Expand Down Expand Up @@ -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<flutter::TizenViewBase*>(view->tizen_view());
return tizen_view->GetNativeHandle();
}

void FlutterDesktopViewResize(FlutterDesktopViewRef view,
int32_t width,
int32_t height) {
Expand Down
10 changes: 0 additions & 10 deletions shell/platform/tizen/flutter_tizen_elementary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,3 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent(

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;
}
16 changes: 8 additions & 8 deletions shell/platform/tizen/public/flutter_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/tizen/tizen_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class TizenView : public TizenViewBase {
TizenView() = default;
virtual ~TizenView() = default;

virtual void* GetRenderTargetContainer() = 0;

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

protected:
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/tizen/tizen_view_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/tizen_view_elementary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions shell/platform/tizen/tizen_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>& rotations) = 0;
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/tizen_window_ecore_wl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>& rotations) override;

void BindKeys(const std::vector<std::string>& keys) override;
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/tizen_window_elementary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>& rotations) override;

void BindKeys(const std::vector<std::string>& keys) override;
Expand Down

0 comments on commit 0948a08

Please sign in to comment.