Skip to content

Commit e3d4a47

Browse files
committed
[tizen_window_manager] Add tizen-core-wl window backend
Introduce a WindowProxyInterface abstraction with two backends selected at runtime by WindowProxy: - TizenCoreWlWindowProxy (tizen-core-wl) on Tizen API version >= 11.0 when the library is available - EcoreWl2WindowProxy (ecore_wl2) otherwise, including as a fallback when tizen-core-wl cannot be loaded on 11.0+ Both backends implement WindowProxyInterface (GetGeometry/Activate/Lower) and resolve their symbols at runtime via dlopen/dlsym. TizenWindowManager constructs WindowProxy, which picks the backend by querying the platform version at startup.
1 parent 1bb8868 commit e3d4a47

9 files changed

Lines changed: 216 additions & 19 deletions

packages/tizen_window_manager/tizen/src/ecore_wl2_window_proxy.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ EcoreWl2WindowProxy::~EcoreWl2WindowProxy() {
2828
}
2929
}
3030

31-
void EcoreWl2WindowProxy::ecore_wl2_window_geometry_get(void *window, int *x,
32-
int *y, int *width,
33-
int *height) {
31+
void EcoreWl2WindowProxy::GetGeometry(void *window, int *x, int *y, int *width,
32+
int *height) {
3433
if (!ecore_wl2_window_handle_) {
3534
LOG_ERROR("ecore_wl2_window_handle_ not valid");
3635
return;
@@ -46,7 +45,7 @@ void EcoreWl2WindowProxy::ecore_wl2_window_geometry_get(void *window, int *x,
4645
ecore_wl2_window_geometry_get(window, x, y, width, height);
4746
}
4847

49-
void EcoreWl2WindowProxy::ecore_wl2_window_activate(void *window) {
48+
void EcoreWl2WindowProxy::Activate(void *window) {
5049
if (!ecore_wl2_window_handle_) {
5150
LOG_ERROR("ecore_wl2_window_handle_ not valid");
5251
return;
@@ -62,7 +61,7 @@ void EcoreWl2WindowProxy::ecore_wl2_window_activate(void *window) {
6261
ecore_wl2_window_activate(window);
6362
}
6463

65-
void EcoreWl2WindowProxy::ecore_wl2_window_lower(void *window) {
64+
void EcoreWl2WindowProxy::Lower(void *window) {
6665
if (!ecore_wl2_window_handle_) {
6766
LOG_ERROR("ecore_wl2_window_handle_ not valid");
6867
return;

packages/tizen_window_manager/tizen/src/ecore_wl2_window_proxy.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
#ifndef FLUTTER_PLUGIN_ECORE_WL2_WINDOW_PROXY_H_
66
#define FLUTTER_PLUGIN_ECORE_WL2_WINDOW_PROXY_H_
77

8-
class EcoreWl2WindowProxy {
8+
#include "window_proxy_interface.h"
9+
10+
class EcoreWl2WindowProxy : public WindowProxyInterface {
911
public:
1012
EcoreWl2WindowProxy();
11-
~EcoreWl2WindowProxy();
12-
void ecore_wl2_window_geometry_get(void *window, int *x, int *y, int *width,
13-
int *height);
13+
~EcoreWl2WindowProxy() override;
1414

15-
void ecore_wl2_window_activate(void *window);
16-
void ecore_wl2_window_lower(void *window);
15+
void GetGeometry(void *window, int *x, int *y, int *width,
16+
int *height) override;
17+
void Activate(void *window) override;
18+
void Lower(void *window) override;
1719

1820
private:
1921
void *ecore_wl2_window_handle_ = nullptr;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "tizen_core_wl_window_proxy.h"
6+
7+
#include <dlfcn.h>
8+
9+
#include "log.h"
10+
11+
TizenCoreWlWindowProxy::TizenCoreWlWindowProxy() {
12+
handle_ = dlopen("libtizen-core-wl.so.0", RTLD_LAZY);
13+
if (handle_ == nullptr) {
14+
LOG_ERROR("Failed to open tizen-core-wl.");
15+
return;
16+
}
17+
18+
get_geometry_ = reinterpret_cast<FuncGetGeometry>(
19+
dlsym(handle_, "tizen_core_wl_window_get_geometry"));
20+
activate_ = reinterpret_cast<FuncActivate>(
21+
dlsym(handle_, "tizen_core_wl_window_activate"));
22+
lower_ = reinterpret_cast<FuncLower>(
23+
dlsym(handle_, "tizen_core_wl_window_lower"));
24+
25+
if (!get_geometry_ || !activate_ || !lower_) {
26+
LOG_ERROR("Failed to resolve tizen-core-wl symbols.");
27+
dlclose(handle_);
28+
handle_ = nullptr;
29+
}
30+
}
31+
32+
TizenCoreWlWindowProxy::~TizenCoreWlWindowProxy() {
33+
if (handle_) {
34+
dlclose(handle_);
35+
handle_ = nullptr;
36+
}
37+
}
38+
39+
void TizenCoreWlWindowProxy::GetGeometry(void *window, int *x, int *y,
40+
int *width, int *height) {
41+
if (!handle_) {
42+
LOG_ERROR("tizen-core-wl handle not valid");
43+
return;
44+
}
45+
get_geometry_(window, x, y, width, height);
46+
}
47+
48+
void TizenCoreWlWindowProxy::Activate(void *window) {
49+
if (!handle_) {
50+
LOG_ERROR("tizen-core-wl handle not valid");
51+
return;
52+
}
53+
activate_(window);
54+
}
55+
56+
void TizenCoreWlWindowProxy::Lower(void *window) {
57+
if (!handle_) {
58+
LOG_ERROR("tizen-core-wl handle not valid");
59+
return;
60+
}
61+
lower_(window);
62+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_
6+
#define FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_
7+
8+
#include "window_proxy_interface.h"
9+
10+
class TizenCoreWlWindowProxy : public WindowProxyInterface {
11+
public:
12+
TizenCoreWlWindowProxy();
13+
~TizenCoreWlWindowProxy() override;
14+
15+
bool IsValid() const { return handle_ != nullptr; }
16+
17+
void GetGeometry(void *window, int *x, int *y, int *width,
18+
int *height) override;
19+
void Activate(void *window) override;
20+
void Lower(void *window) override;
21+
22+
private:
23+
typedef int (*FuncGetGeometry)(void *window, int *x, int *y, int *width,
24+
int *height);
25+
typedef int (*FuncActivate)(void *window);
26+
typedef int (*FuncLower)(void *window);
27+
28+
void *handle_ = nullptr;
29+
FuncGetGeometry get_geometry_ = nullptr;
30+
FuncActivate activate_ = nullptr;
31+
FuncLower lower_ = nullptr;
32+
};
33+
34+
#endif // FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_

packages/tizen_window_manager/tizen/src/tizen_window_manager.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
#include <memory>
1111

12-
#include "ecore_wl2_window_proxy.h"
1312
#include "log.h"
13+
#include "window_proxy.h"
1414

1515
TizenWindowManager::TizenWindowManager(void* handle)
16-
: window_handle_(handle), proxy_(std::make_unique<EcoreWl2WindowProxy>()) {}
16+
: window_handle_(handle), proxy_(std::make_unique<WindowProxy>()) {}
1717

1818
TizenWindowManager::~TizenWindowManager() {}
1919

@@ -22,15 +22,15 @@ void TizenWindowManager::Activate() {
2222
LOG_ERROR("Window handle is null");
2323
}
2424

25-
proxy_->ecore_wl2_window_activate(window_handle_);
25+
proxy_->Activate(window_handle_);
2626
}
2727

2828
void TizenWindowManager::Lower() {
2929
if (!window_handle_) {
3030
LOG_ERROR("Window handle is null");
3131
}
3232

33-
proxy_->ecore_wl2_window_lower(window_handle_);
33+
proxy_->Lower(window_handle_);
3434
}
3535

3636
flutter::EncodableMap TizenWindowManager::GetGeometry() {
@@ -46,8 +46,7 @@ flutter::EncodableMap TizenWindowManager::GetGeometry() {
4646
}
4747

4848
int x, y, width, height;
49-
proxy_->ecore_wl2_window_geometry_get(window_handle_, &x, &y, &width,
50-
&height);
49+
proxy_->GetGeometry(window_handle_, &x, &y, &width, &height);
5150

5251
geometry[flutter::EncodableValue("x")] = flutter::EncodableValue(x);
5352
geometry[flutter::EncodableValue("y")] = flutter::EncodableValue(y);

packages/tizen_window_manager/tizen/src/tizen_window_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <memory>
1212

13-
class EcoreWl2WindowProxy;
13+
class WindowProxy;
1414

1515
class TizenWindowManager {
1616
public:
@@ -23,7 +23,7 @@ class TizenWindowManager {
2323

2424
private:
2525
void* window_handle_;
26-
std::unique_ptr<EcoreWl2WindowProxy> proxy_;
26+
std::unique_ptr<WindowProxy> proxy_;
2727
};
2828

2929
#endif // FLUTTER_PLUGIN_TIZEN_WINDOW_MANAGER_H_
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "window_proxy.h"
6+
7+
#include <system_info.h>
8+
9+
#include <cstdlib>
10+
#include <memory>
11+
#include <utility>
12+
13+
#include "ecore_wl2_window_proxy.h"
14+
#include "log.h"
15+
#include "tizen_core_wl_window_proxy.h"
16+
17+
namespace {
18+
19+
constexpr int kTizenCoreWlMinMajorVersion = 11;
20+
21+
int GetPlatformMajorVersion() {
22+
char *version = nullptr;
23+
int ret = system_info_get_platform_string(
24+
"http://tizen.org/feature/platform.version", &version);
25+
if (ret != SYSTEM_INFO_ERROR_NONE || version == nullptr) {
26+
LOG_ERROR("Failed to get platform version. error: %d", ret);
27+
return 0;
28+
}
29+
30+
int major = std::atoi(version);
31+
free(version);
32+
return major;
33+
}
34+
35+
} // namespace
36+
37+
WindowProxy::WindowProxy() {
38+
if (GetPlatformMajorVersion() >= kTizenCoreWlMinMajorVersion) {
39+
auto proxy = std::make_unique<TizenCoreWlWindowProxy>();
40+
if (proxy->IsValid()) {
41+
LOG_INFO("Using tizen-core-wl backend.");
42+
impl_ = std::move(proxy);
43+
return;
44+
}
45+
LOG_INFO("tizen-core-wl unavailable, falling back to ecore_wl2 backend.");
46+
}
47+
impl_ = std::make_unique<EcoreWl2WindowProxy>();
48+
}
49+
50+
void WindowProxy::GetGeometry(void *window, int *x, int *y, int *width,
51+
int *height) {
52+
impl_->GetGeometry(window, x, y, width, height);
53+
}
54+
55+
void WindowProxy::Activate(void *window) { impl_->Activate(window); }
56+
57+
void WindowProxy::Lower(void *window) { impl_->Lower(window); }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_PLUGIN_WINDOW_PROXY_H_
6+
#define FLUTTER_PLUGIN_WINDOW_PROXY_H_
7+
8+
#include <memory>
9+
10+
#include "window_proxy_interface.h"
11+
12+
class WindowProxy : public WindowProxyInterface {
13+
public:
14+
WindowProxy();
15+
~WindowProxy() override = default;
16+
17+
void GetGeometry(void *window, int *x, int *y, int *width,
18+
int *height) override;
19+
void Activate(void *window) override;
20+
void Lower(void *window) override;
21+
22+
private:
23+
std::unique_ptr<WindowProxyInterface> impl_;
24+
};
25+
26+
#endif // FLUTTER_PLUGIN_WINDOW_PROXY_H_
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_
6+
#define FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_
7+
8+
class WindowProxyInterface {
9+
public:
10+
virtual ~WindowProxyInterface() = default;
11+
12+
virtual void GetGeometry(void *window, int *x, int *y, int *width,
13+
int *height) = 0;
14+
virtual void Activate(void *window) = 0;
15+
virtual void Lower(void *window) = 0;
16+
};
17+
18+
#endif // FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_

0 commit comments

Comments
 (0)