Skip to content

Commit 45cc5b5

Browse files
authored
Introduce TizenViewEventHandlerDelegate and rework FlutterDesktopViewResize (#309)
* `TizenViewEventHandlerDelegate` only provides a limited interface for delegating event handling. * `FlutterDesktopViewResize` should work on all types of views. * Implementations of `TizenViewBase::SetGeometry` only manipulate top-level raw object such as window, container. other components in the view are manipulated on a resize callback. * window channel use `SetGeometry` normally. Signed-off-by: Boram Bae <[email protected]>
1 parent 97c6cd1 commit 45cc5b5

19 files changed

+262
-195
lines changed

shell/platform/tizen/channels/window_channel.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ void WindowChannel::HandleMethodCall(
5858
EncodableValueHolder<int32_t> height(arguments, "height");
5959

6060
TizenGeometry geometry = window_->GetGeometry();
61-
// FIXME: Use SetGeometry() instead of OnGeometryChanged()
62-
// After the SetGeometry was successfully executed, I expected a
63-
// handler of ECORE_WL2_EVENT_WINDOW_CONFIGURE to be called, but it didn't.
64-
window_->OnGeometryChanged({
61+
window_->SetGeometry({
6562
x ? *x : geometry.left,
6663
y ? *y : geometry.top,
6764
width ? *width : geometry.width,

shell/platform/tizen/flutter_tizen.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ FlutterDesktopEngineRef HandleForEngine(flutter::FlutterTizenEngine* engine) {
2727
return reinterpret_cast<FlutterDesktopEngineRef>(engine);
2828
}
2929

30+
// Returns the view corresponding to the given opaque API handle.
31+
flutter::FlutterTizenView* ViewFromHandle(FlutterDesktopViewRef view) {
32+
return reinterpret_cast<flutter::FlutterTizenView*>(view);
33+
}
34+
3035
// Returns the texture registrar corresponding to the given opaque API handle.
3136
flutter::FlutterTizenTextureRegistrar* TextureRegistrarFromHandle(
3237
FlutterDesktopTextureRegistrarRef ref) {
@@ -176,6 +181,12 @@ void FlutterDesktopEngineNotifyAppIsDetached(FlutterDesktopEngineRef engine) {
176181
EngineFromHandle(engine)->lifecycle_channel()->AppIsDetached();
177182
}
178183

184+
void FlutterDesktopViewResize(FlutterDesktopViewRef view,
185+
int32_t width,
186+
int32_t height) {
187+
ViewFromHandle(view)->Resize(width, height);
188+
}
189+
179190
void FlutterDesktopRegisterViewFactory(
180191
FlutterDesktopPluginRegistrarRef registrar,
181192
const char* view_type,

shell/platform/tizen/flutter_tizen_ecore.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,3 @@ void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) {
6363
FT_LOG(Warn) << "Not applicable!";
6464
return nullptr;
6565
}
66-
67-
void FlutterDesktopViewResize(FlutterDesktopViewRef view_ref,
68-
int32_t width,
69-
int32_t height) {
70-
FT_LOG(Warn) << "Not applicable!";
71-
}

shell/platform/tizen/flutter_tizen_elementary.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,3 @@ void* FlutterDesktopViewGetEvasObject(FlutterDesktopViewRef view_ref) {
8787
}
8888
return nullptr;
8989
}
90-
91-
void FlutterDesktopViewResize(FlutterDesktopViewRef view_ref,
92-
int32_t width,
93-
int32_t height) {
94-
auto* view = reinterpret_cast<flutter::FlutterTizenView*>(view_ref);
95-
view->OnResize(0, 0, width, height);
96-
}

shell/platform/tizen/flutter_tizen_view.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ void FlutterTizenView::DestroyRenderSurface() {
103103
}
104104
}
105105

106+
void FlutterTizenView::Resize(int32_t width, int32_t height) {
107+
TizenGeometry geometry = tizen_view_->GetGeometry();
108+
geometry.width = width;
109+
geometry.height = height;
110+
tizen_view_->SetGeometry(geometry);
111+
}
112+
106113
bool FlutterTizenView::OnMakeCurrent() {
107114
return engine_->renderer()->OnMakeCurrent();
108115
}
@@ -135,7 +142,8 @@ void FlutterTizenView::OnResize(int32_t left,
135142
std::swap(width, height);
136143
}
137144

138-
tizen_view_->ResizeWithRotation({left, top, width, height}, rotation_degree_);
145+
engine_->renderer()->ResizeSurface(width, height);
146+
139147
SendWindowMetrics(left, top, width, height, 0.0);
140148
}
141149

@@ -167,8 +175,7 @@ void FlutterTizenView::OnRotate(int32_t degree) {
167175
std::swap(width, height);
168176
}
169177

170-
tizen_view_->ResizeWithRotation({geometry.left, geometry.top, width, height},
171-
rotation_degree_);
178+
engine_->renderer()->ResizeSurface(width, height);
172179

173180
// Window position does not change on rotation regardless of its orientation.
174181
SendWindowMetrics(geometry.left, geometry.top, width, height, 0.0);

shell/platform/tizen/flutter_tizen_view.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#include "flutter/shell/platform/tizen/channels/window_channel.h"
1717
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
1818
#include "flutter/shell/platform/tizen/tizen_view_base.h"
19+
#include "flutter/shell/platform/tizen/tizen_view_event_handler_delegate.h"
1920

2021
namespace flutter {
2122

22-
class FlutterTizenView {
23+
class FlutterTizenView : public TizenViewEventHandlerDelegate {
2324
public:
2425
FlutterTizenView(std::unique_ptr<TizenViewBase> tizen_view);
2526

26-
~FlutterTizenView();
27+
virtual ~FlutterTizenView();
2728

2829
// Configures the window instance with an instance of a running Flutter
2930
// engine.
@@ -40,6 +41,8 @@ class FlutterTizenView {
4041
// Destroys current rendering surface if one has been allocated.
4142
void DestroyRenderSurface();
4243

44+
void Resize(int32_t width, int32_t height);
45+
4346
// Callbacks for clearing context, settings context and swapping buffers,
4447
// these are typically called on an engine-controlled (non-platform) thread.
4548
bool OnMakeCurrent();
@@ -51,27 +54,30 @@ class FlutterTizenView {
5154

5255
void* OnProcResolver(const char* name);
5356

54-
void OnResize(int32_t left, int32_t top, int32_t width, int32_t height);
57+
void OnResize(int32_t left,
58+
int32_t top,
59+
int32_t width,
60+
int32_t height) override;
5561

56-
void OnRotate(int32_t degree);
62+
void OnRotate(int32_t degree) override;
5763

5864
void OnPointerMove(double x,
5965
double y,
6066
size_t timestamp,
6167
FlutterPointerDeviceKind device_kind,
62-
int32_t device_id);
68+
int32_t device_id) override;
6369

6470
void OnPointerDown(double x,
6571
double y,
6672
size_t timestamp,
6773
FlutterPointerDeviceKind device_kind,
68-
int32_t device_id);
74+
int32_t device_id) override;
6975

7076
void OnPointerUp(double x,
7177
double y,
7278
size_t timestamp,
7379
FlutterPointerDeviceKind device_kind,
74-
int32_t device_id);
80+
int32_t device_id) override;
7581

7682
void OnScroll(double x,
7783
double y,
@@ -80,22 +86,22 @@ class FlutterTizenView {
8086
int scroll_offset_multiplier,
8187
size_t timestamp,
8288
FlutterPointerDeviceKind device_kind,
83-
int32_t device_id);
89+
int32_t device_id) override;
8490

8591
void OnKey(const char* key,
8692
const char* string,
8793
const char* compose,
8894
uint32_t modifiers,
8995
uint32_t scan_code,
90-
bool is_down);
96+
bool is_down) override;
9197

92-
void OnComposeBegin();
98+
void OnComposeBegin() override;
9399

94-
void OnComposeChange(const std::string& str, int cursor_pos);
100+
void OnComposeChange(const std::string& str, int cursor_pos) override;
95101

96-
void OnComposeEnd();
102+
void OnComposeEnd() override;
97103

98-
void OnCommit(const std::string& str);
104+
void OnCommit(const std::string& str) override;
99105

100106
FlutterTransformation GetFlutterTransformation() {
101107
return flutter_transformation_;

shell/platform/tizen/tizen_renderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class TizenRenderer {
3838

3939
virtual bool IsSupportedExtension(const char* name) = 0;
4040

41+
virtual void ResizeSurface(int32_t width, int32_t height) = 0;
42+
4143
protected:
4244
bool is_valid_ = false;
4345
};

shell/platform/tizen/tizen_renderer_egl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ bool TizenRendererEgl::IsSupportedExtension(const char* name) {
271271
return strstr(egl_extension_str_.c_str(), name);
272272
}
273273

274+
void TizenRendererEgl::ResizeSurface(int32_t width, int32_t height) {
275+
// Do nothing.
276+
}
277+
274278
void* TizenRendererEgl::OnProcResolver(const char* name) {
275279
auto address = eglGetProcAddress(name);
276280
if (address != nullptr) {

shell/platform/tizen/tizen_renderer_egl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class TizenRendererEgl : public TizenRenderer {
4040

4141
bool IsSupportedExtension(const char* name) override;
4242

43+
void ResizeSurface(int32_t width, int32_t height) override;
44+
4345
private:
4446
bool ChooseEGLConfiguration();
4547

shell/platform/tizen/tizen_renderer_evas_gl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TizenRendererEvasGL : public TizenRenderer {
4747

4848
void MarkPixelsDirty();
4949

50-
void ResizeSurface(int32_t width, int32_t height);
50+
void ResizeSurface(int32_t width, int32_t height) override;
5151

5252
private:
5353
Evas_GL* evas_gl_ = nullptr;

0 commit comments

Comments
 (0)