1 #include "wrt/src/browser/wrt_window_tree_host.h"
3 #include <tizen-extension-client-protocol.h>
5 #include "tizen_src/chromium_impl/ui/ozone/platform/efl/efl_window.h"
6 #include "ui/display/screen.h"
12 const struct tizen_policy_listener policy_listener = {
13 [](void*, struct tizen_policy*, struct wl_surface*, uint32_t is_conformant) {
14 LOG(INFO) << "Conformant - " << is_conformant;
16 [](void*, struct tizen_policy*, struct wl_surface*, uint32_t conformant_part,
17 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h) {
18 gfx::Rect rect(x, y, w, h);
19 LOG(INFO) << "Conformant Area - part:" << conformant_part << " state:"
20 << state << ") rect:" << rect.ToString();
22 [](void*, struct tizen_policy*, struct wl_surface*, int32_t, uint32_t) {},
23 [](void*, struct tizen_policy*, uint32_t) {},
24 [](void*, struct tizen_policy*, struct wl_surface*, uint32_t, uint32_t) {},
25 [](void*, struct tizen_policy*, struct wl_surface*, uint32_t, uint32_t) {},
26 [](void*, struct tizen_policy*, struct wl_surface*, struct wl_array*,
28 [](void*, struct tizen_policy*, struct wl_surface*, int) {},
29 [](void*, struct tizen_policy*, struct wl_surface*, const char*, const char*,
31 [](void*, struct tizen_policy*, struct wl_surface*, uint32_t, uint32_t,
32 int32_t, int32_t, int32_t, int32_t, uint32_t) {}
37 WRTWindowTreeHost::WRTWindowTreeHost(
38 ui::PlatformWindowInitProperties properties,
39 std::unique_ptr<aura::Window> window)
40 : aura::WindowTreeHostPlatform(std::move(properties), std::move(window)) {
41 #if defined(USE_WAYLAND)
42 auto display = ecore_wl2_connected_display_get(nullptr);
43 auto* globals = ecore_wl2_display_globals_get(display);
45 auto* registry = ecore_wl2_display_registry_get(display);
46 Ecore_Wl2_Global* global;
47 EINA_ITERATOR_FOREACH(globals, global) {
48 if (strcmp(global->interface, tizen_policy_interface.name) == 0) {
49 tizen_policy_ = static_cast<tizen_policy*>(wl_registry_bind(
50 registry, global->id, &tizen_policy_interface, global->version));
55 tizen_policy_add_listener(tizen_policy_, &policy_listener, this);
57 LOG(ERROR) << "wl_registry_bind(tizen_policy_interface) is failed.";
62 auto* root_window = this->window();
65 aura::client::SetWindowParentingClient(root_window, this);
67 OnActivationChanged(true);
70 WRTWindowTreeHost::~WRTWindowTreeHost() {
71 auto* root_window = window();
72 aura::client::SetWindowParentingClient(root_window, nullptr);
74 #if defined(USE_WAYLAND)
76 tizen_policy_destroy(tizen_policy_);
81 WRTWindowTreeHost* WRTWindowTreeHost::Create(ui::PlatformWindowType type) {
82 ui::PlatformWindowInitProperties properties;
84 display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
85 properties.type = type;
86 auto window = std::make_unique<aura::Window>(
87 nullptr, aura::client::WINDOW_TYPE_UNKNOWN);
88 return new WRTWindowTreeHost(std::move(properties), std::move(window));
91 void WRTWindowTreeHost::Hide() {
92 platform_window()->Hide();
95 Evas_Object* WRTWindowTreeHost::GetEvasObject() const {
96 auto* efl_window = static_cast<const ui::EflWindow*>(platform_window());
97 return efl_window->native_view();
100 void WRTWindowTreeHost::OnClosed() {
101 SetPlatformWindow(nullptr);
104 void WRTWindowTreeHost::OnActivationChanged(bool active) {
105 if (is_active_ == active)
108 aura::WindowTreeHostPlatform::OnActivationChanged(active);
111 gfx::Rect WRTWindowTreeHost::GetTransformedRootWindowBoundsFromPixelSize(
112 const gfx::Size& size_in_pixels) const {
113 return gfx::Rect(size_in_pixels);
116 void WRTWindowTreeHost::DispatchEvent(ui::Event* event) {
117 aura::WindowTreeHostPlatform::DispatchEvent(event);
120 aura::Window* WRTWindowTreeHost::GetDefaultParent(
121 aura::Window* window, const gfx::Rect& bounds, const int64_t display_id) {
122 return this->window();