Skip to content

Commit 0948a08

Browse files
authored
Add FlutterDesktopViewGetNativeHandle (#314)
Makes all tizen view types be able to get target container handle. Signed-off-by: swan.seo <[email protected]>
1 parent c60bdea commit 0948a08

File tree

9 files changed

+24
-34
lines changed

9 files changed

+24
-34
lines changed

shell/platform/tizen/flutter_tizen.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,9 @@ void FlutterDesktopEngineShutdown(FlutterDesktopEngineRef engine_ref) {
8282
delete engine;
8383
}
8484

85-
void* FlutterDesktopPluginRegistrarGetNativeWindow(
85+
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(
8686
FlutterDesktopPluginRegistrarRef registrar) {
87-
flutter::TizenViewBase* tizen_view = registrar->engine->view()->tizen_view();
88-
if (tizen_view->GetType() == flutter::TizenViewType::kWindow) {
89-
auto* window = reinterpret_cast<flutter::TizenWindow*>(tizen_view);
90-
return window->GetWindowHandle();
91-
}
92-
return nullptr;
87+
return HandleForView(registrar->engine->view());
9388
}
9489

9590
void FlutterDesktopPluginRegistrarEnableInputBlocking(
@@ -233,6 +228,13 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow(
233228
return HandleForView(view.release());
234229
}
235230

231+
void* FlutterDesktopViewGetNativeHandle(FlutterDesktopViewRef view_ref) {
232+
flutter::FlutterTizenView* view = ViewFromHandle(view_ref);
233+
auto* tizen_view =
234+
reinterpret_cast<flutter::TizenViewBase*>(view->tizen_view());
235+
return tizen_view->GetNativeHandle();
236+
}
237+
236238
void FlutterDesktopViewResize(FlutterDesktopViewRef view,
237239
int32_t width,
238240
int32_t height) {

shell/platform/tizen/flutter_tizen_elementary.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,3 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent(
4747

4848
return HandleForView(view.release());
4949
}
50-
51-
void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) {
52-
auto* view = reinterpret_cast<flutter::FlutterTizenView*>(view_ref);
53-
if (view->tizen_view()->GetType() == flutter::TizenViewType::kView) {
54-
auto* tizen_view =
55-
reinterpret_cast<flutter::TizenView*>(view->tizen_view());
56-
return tizen_view->GetRenderTargetContainer();
57-
}
58-
return nullptr;
59-
}

shell/platform/tizen/public/flutter_tizen.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent(
167167
// @warning This API is a work-in-progress and may change.
168168
FLUTTER_EXPORT void FlutterDesktopViewDestroy(FlutterDesktopViewRef view);
169169

170-
// Returns a handle to evas object that the FlutterView is drawn to.
170+
// Returns a native UI toolkit handle for manipulation in host application.
171171
//
172-
// Cast the returned void* to Evas_Object*.
172+
// Cast the returned void*
173+
// - view elementary : to Evas_Object*.
174+
// - window elementary : to Evas_Object*
175+
// - window ecore wl2 : to Ecore_Wl2_Window*
173176
// @warning This API is a work-in-progress and may change.
174-
FLUTTER_EXPORT void* FlutterDesktopViewGetEvasObject(
177+
FLUTTER_EXPORT void* FlutterDesktopViewGetNativeHandle(
175178
FlutterDesktopViewRef view);
176179

177180
// Resizes the view.
@@ -182,11 +185,8 @@ FLUTTER_EXPORT void FlutterDesktopViewResize(FlutterDesktopViewRef view,
182185

183186
// ========== Plugin Registrar (extensions) ==========
184187

185-
// Returns the window associated with this registrar's engine instance.
186-
//
187-
// If the app runs on a wearable device, cast void* to Evas_Object*,
188-
// otherwise cast it to Ecore_Wl2_Window*.
189-
FLUTTER_EXPORT void* FlutterDesktopPluginRegistrarGetNativeWindow(
188+
// Returns the view associated with this registrar's engine instance.
189+
FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(
190190
FlutterDesktopPluginRegistrarRef registrar);
191191

192192
#if defined(__cplusplus)

shell/platform/tizen/tizen_view.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class TizenView : public TizenViewBase {
1818
TizenView() = default;
1919
virtual ~TizenView() = default;
2020

21-
virtual void* GetRenderTargetContainer() = 0;
22-
2321
TizenViewType GetType() override { return TizenViewType::kView; };
2422

2523
protected:

shell/platform/tizen/tizen_view_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class TizenViewBase {
3030
// by the rendering backend.
3131
virtual void* GetRenderTarget() = 0;
3232

33+
virtual void* GetNativeHandle() = 0;
34+
3335
virtual uintptr_t GetWindowId() = 0;
3436

3537
// Returns the geometry of the view.

shell/platform/tizen/tizen_view_elementary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TizenViewElementary : public TizenView {
3030

3131
void* GetRenderTarget() override { return image_; }
3232

33-
void* GetRenderTargetContainer() override { return container_; }
33+
void* GetNativeHandle() override { return container_; }
3434

3535
int32_t GetDpi() override;
3636

shell/platform/tizen/tizen_window.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class TizenWindow : public TizenViewBase {
1919
TizenWindow() = default;
2020
virtual ~TizenWindow() = default;
2121

22-
virtual void* GetWindowHandle() = 0;
23-
2422
virtual int32_t GetRotation() = 0;
2523

2624
virtual void SetPreferredOrientations(const std::vector<int>& rotations) = 0;

shell/platform/tizen/tizen_window_ecore_wl2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class TizenWindowEcoreWl2 : public TizenWindow {
3636

3737
void* GetRenderTargetDisplay() override { return wl2_display_; }
3838

39+
void* GetNativeHandle() override { return ecore_wl2_window_; }
40+
3941
int32_t GetRotation() override;
4042

4143
int32_t GetDpi() override;
4244

4345
uintptr_t GetWindowId() override;
4446

45-
void* GetWindowHandle() override { return ecore_wl2_window_; }
46-
4747
void SetPreferredOrientations(const std::vector<int>& rotations) override;
4848

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

shell/platform/tizen/tizen_window_elementary.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ class TizenWindowElementary : public TizenWindow {
3535

3636
void* GetRenderTargetDisplay() override { return nullptr; }
3737

38+
void* GetNativeHandle() override { return elm_win_; }
39+
3840
int32_t GetRotation() override;
3941

4042
int32_t GetDpi() override;
4143

4244
uintptr_t GetWindowId() override;
4345

44-
void* GetWindowHandle() override { return elm_win_; }
45-
4646
void SetPreferredOrientations(const std::vector<int>& rotations) override;
4747

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

0 commit comments

Comments
 (0)