Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ EcoreWl2WindowProxy::~EcoreWl2WindowProxy() {
}
}

void EcoreWl2WindowProxy::ecore_wl2_window_geometry_get(void *window, int *x,
int *y, int *width,
int *height) {
void EcoreWl2WindowProxy::GetGeometry(void *window, int *x, int *y, int *width,
int *height) {
if (!ecore_wl2_window_handle_) {
LOG_ERROR("ecore_wl2_window_handle_ not valid");
return;
Expand All @@ -46,7 +45,7 @@ void EcoreWl2WindowProxy::ecore_wl2_window_geometry_get(void *window, int *x,
ecore_wl2_window_geometry_get(window, x, y, width, height);
}

void EcoreWl2WindowProxy::ecore_wl2_window_activate(void *window) {
void EcoreWl2WindowProxy::Activate(void *window) {
if (!ecore_wl2_window_handle_) {
LOG_ERROR("ecore_wl2_window_handle_ not valid");
return;
Expand All @@ -62,7 +61,7 @@ void EcoreWl2WindowProxy::ecore_wl2_window_activate(void *window) {
ecore_wl2_window_activate(window);
}

void EcoreWl2WindowProxy::ecore_wl2_window_lower(void *window) {
void EcoreWl2WindowProxy::Lower(void *window) {
if (!ecore_wl2_window_handle_) {
LOG_ERROR("ecore_wl2_window_handle_ not valid");
return;
Expand Down
14 changes: 8 additions & 6 deletions packages/tizen_window_manager/tizen/src/ecore_wl2_window_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
#ifndef FLUTTER_PLUGIN_ECORE_WL2_WINDOW_PROXY_H_
#define FLUTTER_PLUGIN_ECORE_WL2_WINDOW_PROXY_H_

class EcoreWl2WindowProxy {
#include "window_proxy_interface.h"

class EcoreWl2WindowProxy : public WindowProxyInterface {
public:
EcoreWl2WindowProxy();
~EcoreWl2WindowProxy();
void ecore_wl2_window_geometry_get(void *window, int *x, int *y, int *width,
int *height);
~EcoreWl2WindowProxy() override;

void ecore_wl2_window_activate(void *window);
void ecore_wl2_window_lower(void *window);
void GetGeometry(void *window, int *x, int *y, int *width,
int *height) override;
void Activate(void *window) override;
void Lower(void *window) override;

private:
void *ecore_wl2_window_handle_ = nullptr;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "tizen_core_wl_window_proxy.h"

#include <dlfcn.h>

#include "log.h"

TizenCoreWlWindowProxy::TizenCoreWlWindowProxy() {
handle_ = dlopen("libtizen-core-wl.so.0", RTLD_LAZY);
if (handle_ == nullptr) {
LOG_ERROR("Failed to open tizen-core-wl.");
return;
}

get_geometry_ = reinterpret_cast<FuncGetGeometry>(
dlsym(handle_, "tizen_core_wl_window_get_geometry"));
activate_ = reinterpret_cast<FuncActivate>(
dlsym(handle_, "tizen_core_wl_window_activate"));
lower_ =
reinterpret_cast<FuncLower>(dlsym(handle_, "tizen_core_wl_window_lower"));

if (!get_geometry_ || !activate_ || !lower_) {
LOG_ERROR("Failed to resolve tizen-core-wl symbols.");
dlclose(handle_);
handle_ = nullptr;
}
}

TizenCoreWlWindowProxy::~TizenCoreWlWindowProxy() {
if (handle_) {
dlclose(handle_);
handle_ = nullptr;
}
}

void TizenCoreWlWindowProxy::GetGeometry(void *window, int *x, int *y,
int *width, int *height) {
if (!handle_) {
LOG_ERROR("tizen-core-wl handle not valid");
return;
}
get_geometry_(window, x, y, width, height);
}

void TizenCoreWlWindowProxy::Activate(void *window) {
if (!handle_) {
LOG_ERROR("tizen-core-wl handle not valid");
return;
}
activate_(window);
}

void TizenCoreWlWindowProxy::Lower(void *window) {
if (!handle_) {
LOG_ERROR("tizen-core-wl handle not valid");
return;
}
lower_(window);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_
#define FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_

#include "window_proxy_interface.h"

class TizenCoreWlWindowProxy : public WindowProxyInterface {
public:
TizenCoreWlWindowProxy();
~TizenCoreWlWindowProxy() override;

bool IsValid() const { return handle_ != nullptr; }

void GetGeometry(void *window, int *x, int *y, int *width,
int *height) override;
void Activate(void *window) override;
void Lower(void *window) override;

private:
typedef int (*FuncGetGeometry)(void *window, int *x, int *y, int *width,
int *height);
typedef int (*FuncActivate)(void *window);
typedef int (*FuncLower)(void *window);

void *handle_ = nullptr;
FuncGetGeometry get_geometry_ = nullptr;
FuncActivate activate_ = nullptr;
FuncLower lower_ = nullptr;
};
Comment thread
JSUYA marked this conversation as resolved.

#endif // FLUTTER_PLUGIN_TIZEN_CORE_WL_WINDOW_PROXY_H_
11 changes: 5 additions & 6 deletions packages/tizen_window_manager/tizen/src/tizen_window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

#include <memory>

#include "ecore_wl2_window_proxy.h"
#include "log.h"
#include "window_proxy.h"

TizenWindowManager::TizenWindowManager(void* handle)
: window_handle_(handle), proxy_(std::make_unique<EcoreWl2WindowProxy>()) {}
: window_handle_(handle), proxy_(std::make_unique<WindowProxy>()) {}

TizenWindowManager::~TizenWindowManager() {}

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

proxy_->ecore_wl2_window_activate(window_handle_);
proxy_->Activate(window_handle_);
}

void TizenWindowManager::Lower() {
if (!window_handle_) {
LOG_ERROR("Window handle is null");
}

proxy_->ecore_wl2_window_lower(window_handle_);
proxy_->Lower(window_handle_);
}

flutter::EncodableMap TizenWindowManager::GetGeometry() {
Expand All @@ -46,8 +46,7 @@ flutter::EncodableMap TizenWindowManager::GetGeometry() {
}

int x, y, width, height;
proxy_->ecore_wl2_window_geometry_get(window_handle_, &x, &y, &width,
&height);
proxy_->GetGeometry(window_handle_, &x, &y, &width, &height);

geometry[flutter::EncodableValue("x")] = flutter::EncodableValue(x);
geometry[flutter::EncodableValue("y")] = flutter::EncodableValue(y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <memory>

class EcoreWl2WindowProxy;
class WindowProxy;

class TizenWindowManager {
public:
Expand All @@ -23,7 +23,7 @@ class TizenWindowManager {

private:
void* window_handle_;
std::unique_ptr<EcoreWl2WindowProxy> proxy_;
std::unique_ptr<WindowProxy> proxy_;
};

#endif // FLUTTER_PLUGIN_TIZEN_WINDOW_MANAGER_H_
57 changes: 57 additions & 0 deletions packages/tizen_window_manager/tizen/src/window_proxy.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "window_proxy.h"

#include <system_info.h>

#include <cstdlib>
#include <memory>
#include <utility>

#include "ecore_wl2_window_proxy.h"
#include "log.h"
#include "tizen_core_wl_window_proxy.h"

namespace {

constexpr int kTizenCoreWlMinMajorVersion = 11;

int GetPlatformMajorVersion() {
char *version = nullptr;
int ret = system_info_get_platform_string(
"http://tizen.org/feature/platform.version", &version);
if (ret != SYSTEM_INFO_ERROR_NONE || version == nullptr) {
LOG_ERROR("Failed to get platform version. error: %d", ret);
return 0;
}

int major = std::atoi(version);
free(version);
return major;
}

} // namespace

WindowProxy::WindowProxy() {
if (GetPlatformMajorVersion() >= kTizenCoreWlMinMajorVersion) {
auto proxy = std::make_unique<TizenCoreWlWindowProxy>();
if (proxy->IsValid()) {
LOG_INFO("Using tizen-core-wl backend.");
impl_ = std::move(proxy);
return;
}
LOG_INFO("tizen-core-wl unavailable, falling back to ecore_wl2 backend.");
}
impl_ = std::make_unique<EcoreWl2WindowProxy>();
}

void WindowProxy::GetGeometry(void *window, int *x, int *y, int *width,
int *height) {
impl_->GetGeometry(window, x, y, width, height);
}

void WindowProxy::Activate(void *window) { impl_->Activate(window); }

void WindowProxy::Lower(void *window) { impl_->Lower(window); }
26 changes: 26 additions & 0 deletions packages/tizen_window_manager/tizen/src/window_proxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_PLUGIN_WINDOW_PROXY_H_
#define FLUTTER_PLUGIN_WINDOW_PROXY_H_

#include <memory>

#include "window_proxy_interface.h"

class WindowProxy : public WindowProxyInterface {
public:
WindowProxy();
~WindowProxy() override = default;

void GetGeometry(void *window, int *x, int *y, int *width,
int *height) override;
void Activate(void *window) override;
void Lower(void *window) override;

private:
std::unique_ptr<WindowProxyInterface> impl_;
};

#endif // FLUTTER_PLUGIN_WINDOW_PROXY_H_
18 changes: 18 additions & 0 deletions packages/tizen_window_manager/tizen/src/window_proxy_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_
#define FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_

class WindowProxyInterface {
public:
virtual ~WindowProxyInterface() = default;

virtual void GetGeometry(void *window, int *x, int *y, int *width,
int *height) = 0;
virtual void Activate(void *window) = 0;
virtual void Lower(void *window) = 0;
};

#endif // FLUTTER_PLUGIN_WINDOW_PROXY_INTERFACE_H_
Loading