Skip to content

Commit 56c9c35

Browse files
committed
Support user made window
* This is a necessary feature for partial window. Signed-off-by: MuHong Byun <[email protected]>
1 parent 9f08d18 commit 56c9c35

7 files changed

+52
-24
lines changed

shell/platform/tizen/flutter_tizen.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine(
2929
bool headed) {
3030
StartLogging();
3131

32-
auto engine = std::make_unique<FlutterTizenEngine>(headed);
32+
auto engine = std::make_unique<FlutterTizenEngine>(
33+
headed, engine_properties.custom_win);
3334
if (!engine->RunEngine(engine_properties)) {
3435
FT_LOGE("Failed to run the Flutter engine.");
3536
return nullptr;

shell/platform/tizen/flutter_tizen_engine.cc

+9-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static DeviceProfile GetDeviceProfile() {
3838
return DeviceProfile::kUnknown;
3939
}
4040

41-
FlutterTizenEngine::FlutterTizenEngine(bool headed)
42-
: device_profile(GetDeviceProfile()) {
41+
FlutterTizenEngine::FlutterTizenEngine(bool headed, void* win)
42+
: device_profile(GetDeviceProfile()), custom_window_(win) {
4343
// Run flutter task on Tizen main loop.
4444
// Tizen engine has four threads (GPU thread, UI thread, IO thread, platform
4545
// thread). UI threads need to send flutter task to platform thread.
@@ -331,6 +331,13 @@ void FlutterTizenEngine::OnOrientationChange(int32_t degree) {
331331
SetWindowOrientation(degree);
332332
}
333333

334+
bool FlutterTizenEngine::hasCustomWindow() {
335+
return custom_window_ != nullptr;
336+
}
337+
void* FlutterTizenEngine::CustomWindow() {
338+
return custom_window_;
339+
}
340+
334341
// The Flutter Engine calls out to this function when new platform messages are
335342
// available.
336343
void FlutterTizenEngine::OnFlutterPlatformMessage(

shell/platform/tizen/flutter_tizen_engine.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum DeviceProfile { kUnknown, kMobile, kWearable, kTV, kCommon };
5858
// Manages state associated with the underlying FlutterEngine.
5959
class FlutterTizenEngine : public TizenRenderer::Delegate {
6060
public:
61-
explicit FlutterTizenEngine(bool headed);
61+
explicit FlutterTizenEngine(bool headed, void* win = nullptr);
6262
virtual ~FlutterTizenEngine();
6363

6464
// Prevent copying.
@@ -83,6 +83,9 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
8383
void SetWindowOrientation(int32_t degree);
8484
void OnOrientationChange(int32_t degree) override;
8585

86+
// This is an experimental feature to support partial window.
87+
bool hasCustomWindow() override;
88+
void* CustomWindow() override;
8689
// The Flutter engine instance.
8790
FLUTTER_API_SYMBOL(FlutterEngine) flutter_engine;
8891

@@ -152,6 +155,8 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
152155

153156
// The current renderer transformation.
154157
FlutterTransformation transformation_;
158+
159+
void* custom_window_;
155160
};
156161

157162
#endif // EMBEDDER_TIZEN_EMBEDDER_ENGINE_H_

shell/platform/tizen/public/flutter_tizen.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ typedef struct {
3636
const char** switches;
3737
// The number of elements in |switches|.
3838
size_t switches_count;
39+
// This is an experimental feature to support partial window.
40+
void* custom_win;
3941
} FlutterDesktopEngineProperties;
4042

4143
// Runs an instance of a Flutter engine with the given properties.

shell/platform/tizen/tizen_renderer.h

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class TizenRenderer {
1717
class Delegate {
1818
public:
1919
virtual void OnOrientationChange(int32_t degree) = 0;
20+
// This is an experimental feature to support partial window.
21+
virtual bool hasCustomWindow() = 0;
22+
virtual void* CustomWindow() = 0;
2023
};
2124

2225
virtual ~TizenRenderer();

shell/platform/tizen/tizen_renderer_ecore_wl2.cc

+13-7
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,19 @@ bool TizenRendererEcoreWl2::SetupEcoreWlWindow(int32_t width, int32_t height) {
285285
FT_LOGE("Invalid screen size: %d x %d", width, height);
286286
return false;
287287
}
288-
ecore_wl2_window_ =
289-
ecore_wl2_window_new(ecore_wl2_display_, nullptr, 0, 0, width, height);
290-
ecore_wl2_window_type_set(ecore_wl2_window_, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
291-
ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE);
292-
ecore_wl2_window_position_set(ecore_wl2_window_, 0, 0);
293-
ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0,
294-
"wm.policy.win.user.geometry", "1");
288+
if (delegate_.hasCustomWindow()) {
289+
ecore_wl2_window_ =
290+
reinterpret_cast<Ecore_Wl2_Window*>(delegate_.CustomWindow());
291+
} else {
292+
ecore_wl2_window_ =
293+
ecore_wl2_window_new(ecore_wl2_display_, nullptr, 0, 0, width, height);
294+
ecore_wl2_window_type_set(ecore_wl2_window_,
295+
ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
296+
ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE);
297+
ecore_wl2_window_position_set(ecore_wl2_window_, 0, 0);
298+
ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0,
299+
"wm.policy.win.user.geometry", "1");
300+
}
295301
int rotations[4] = {0, 90, 180, 270};
296302
ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations,
297303
sizeof(rotations) / sizeof(int));

shell/platform/tizen/tizen_renderer_evas_gl.cc

+17-13
Original file line numberDiff line numberDiff line change
@@ -636,21 +636,25 @@ bool TizenRendererEvasGL::SetupEvasGL() {
636636
void* TizenRendererEvasGL::SetupEvasWindow(int32_t& width, int32_t& height) {
637637
elm_config_accel_preference_set("hw:opengl");
638638

639-
evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
640-
auto* ecore_evas =
641-
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_));
642-
int32_t x, y;
643-
ecore_evas_screen_geometry_get(ecore_evas, &x, &y, &width, &height);
644-
if (width == 0 || height == 0) {
645-
FT_LOGE("Invalid screen size: %d x %d", width, height);
646-
return nullptr;
639+
if (delegate_.hasCustomWindow()) {
640+
evas_window_ = reinterpret_cast<Evas_Object*>(delegate_.CustomWindow());
641+
} else {
642+
evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
643+
auto* ecore_evas =
644+
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_));
645+
int32_t x, y;
646+
ecore_evas_screen_geometry_get(ecore_evas, &x, &y, &width, &height);
647+
if (width == 0 || height == 0) {
648+
FT_LOGE("Invalid screen size: %d x %d", width, height);
649+
return nullptr;
650+
}
651+
652+
elm_win_alpha_set(evas_window_, EINA_FALSE);
653+
evas_object_move(evas_window_, 0, 0);
654+
evas_object_resize(evas_window_, width, height);
655+
evas_object_raise(evas_window_);
647656
}
648657

649-
elm_win_alpha_set(evas_window_, EINA_FALSE);
650-
evas_object_move(evas_window_, 0, 0);
651-
evas_object_resize(evas_window_, width, height);
652-
evas_object_raise(evas_window_);
653-
654658
Evas_Object* bg = elm_bg_add(evas_window_);
655659
evas_object_color_set(bg, 0x00, 0x00, 0x00, 0x00);
656660

0 commit comments

Comments
 (0)