namespace {
-Ecore_Evas* prepared_ee = nullptr;
+#if defined(USE_WAYLAND)
+Ecore_Wl2_Window_Type GetEcoreWl2WindowType(PlatformWindowType type) {
+ Ecore_Wl2_Window_Type window_type = ECORE_WL2_WINDOW_TYPE_NONE;
+
+ switch (type) {
+ case PlatformWindowType::kWindow:
+ window_type = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
+ break;
+ case PlatformWindowType::kPopup:
+ case PlatformWindowType::kMenu:
+ case PlatformWindowType::kTooltip:
+ case PlatformWindowType::kBubble:
+ window_type = ECORE_WL2_WINDOW_TYPE_UTILITY;
+ break;
+ case PlatformWindowType::kDrag:
+ window_type = ECORE_WL2_WINDOW_TYPE_DND;
+ break;
+ default:
+ window_type = ECORE_WL2_WINDOW_TYPE_NONE;
+ }
+
+ return window_type;
+}
+#endif
+
+bool g_evas_init = false;
} // namespace
+Ecore_Evas* prepared_ee = nullptr;
+
#if BUILDFLAG(IS_TIZEN_TV)
bool EflWindow::is_cursor_initialized_ = false;
#endif
switches::kEnableOffscreenRendering))
return;
-#if defined(ENABLE_WRT_JS)
- // For now, only show kWindow and kSplashScreen, ignore other types : kMenu,
- // kTootltip etc.
- if (type_ != PlatformWindowType::kWindow &&
- type_ != PlatformWindowType::kSplashScreen) {
- return;
- }
-#else
- // For now, only show kWindow and ignore other types : kMenu, kTootltip etc.
- if (type_ != PlatformWindowType::kWindow)
- return;
-#endif
-
if (events_overlay_)
evas_object_show(events_overlay_);
-
+#if defined(USE_WAYLAND)
+ ecore_wl2_window_show(wl_window_);
+#endif
ecore_evas_show(ee_);
// Request to redraw window surface when showing. If not, a black screen will
switches::kEnableOffscreenRendering))
return;
- if (type_ != PlatformWindowType::kWindow)
- return;
-
if (events_overlay_)
evas_object_hide(events_overlay_);
-
+#if defined(USE_WAYLAND)
+ ecore_wl2_window_hide(wl_window_);
+#endif
ecore_evas_hide(ee_);
}
}
bool EflWindow::IsVisible() const {
- NOTIMPLEMENTED();
- return false;
+ return ecore_evas_visibility_get(ee_);
}
void EflWindow::PrepareForShutdown() {
return;
}
+ int rotation = ecore_evas_rotation_get(ee_);
+ LOG(INFO) << " bounds " << bounds.ToString() << " rotation " << rotation;
+
#if defined(USE_WAYLAND)
+ ecore_wl2_window_rotation_geometry_set(wl_window_, rotation, bounds.x(),
+ bounds.y(), bounds.width(),
+ bounds.height());
+
if (wl2_egl_window_) {
ecore_wl2_egl_window_resize_with_rotation(wl2_egl_window_, bounds.x(),
bounds.y(), bounds.width(),
}
void EflWindow::SetCapture() {
- NOTIMPLEMENTED();
+ if (!HasCapture()) {
+ window_manager_->GrabLocatedEvents(this);
+ }
}
void EflWindow::ReleaseCapture() {
- NOTIMPLEMENTED();
+ if (HasCapture()) {
+ window_manager_->UngrabLocatedEvents(this);
+ }
}
bool EflWindow::HasCapture() const {
- NOTIMPLEMENTED();
- return false;
+ return window_manager_->located_events_grabber() == this;
}
void EflWindow::SetFullscreen(bool fullscreen, int64_t target_display_id) {
}
PlatformWindowState EflWindow::GetPlatformWindowState() const {
- NOTIMPLEMENTED();
return PlatformWindowState::kNormal;
}
return;
has_focus_ = focused;
+
+ if (events_overlay_) {
+ evas_object_focus_set(events_overlay_, focused);
+ }
+
if (!focused)
return;
window_manager_->UpdateWindowFocus(this, focused);
}
-uint32_t EflWindow::DispatchEvent(const PlatformEvent& event) {
+uint32_t EflWindow::DispatchEvent(const PlatformEvent& native_event) {
+ Event* event = static_cast<Event*>(native_event);
+
+ if (event->IsLocatedEvent()) {
+ auto* event_grabber = window_manager_->located_events_grabber();
+ if (event_grabber) {
+ // The origin of the submenu event needs to be changed to the root menu.
+ efl_event_handler_->ConvertOriginToTarget(event_grabber,
+ event->AsLocatedEvent());
+ event_grabber->DispatchEventToDelegate(event);
+ return POST_DISPATCH_STOP_PROPAGATION;
+ }
+ }
+
+ return DispatchEventToDelegate(event);
+}
+
+void EflWindow::OnWindowLostCapture() {
+ delegate_->OnLostCapture();
+}
+
+uint32_t EflWindow::DispatchEventToDelegate(const PlatformEvent& event) {
bool handled = DispatchEventFromNativeUiEvent(
event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
base::Unretained(delegate_)));
return;
}
- ecore_evas_init();
- evas_init();
+ if (!g_evas_init) {
+ ecore_evas_init();
+ evas_init();
+ g_evas_init = true;
+ }
if (prepared_ee) {
LOG(INFO) << "Use prepared ee instance";
ecore_evas_manual_render_set(ee_, EINA_TRUE);
#if defined(USE_WAYLAND)
- Ecore_Wl2_Window* ww = ecore_evas_wayland2_window_get(ee_);
- if (!ww) {
+ wl_window_ = ecore_evas_wayland2_window_get(ee_);
+ if (!wl_window_) {
LOG(ERROR) << "Failed to get Wl2 window";
return;
}
-
- wl2_egl_window_ =
- ecore_wl2_egl_window_create(ww, bounds_.width(), bounds_.height());
+ wl2_egl_window_ = ecore_wl2_egl_window_create(wl_window_, bounds_.width(),
+ bounds_.height());
if (!wl2_egl_window_) {
LOG(ERROR) << "Failed to create wl2 egl window";
return;
#if defined(TIZEN_VIDEO_HOLE)
// Hand a window handle to enable video hole in OnscreenRendering mode.
media::VideoPlaneController::SetSharedVideoWindowHandle(
- ww, media::VideoPlaneController::RenderingMode::ONSCREEN);
+ wl_window_, media::VideoPlaneController::RenderingMode::ONSCREEN);
#endif
void* egl_window = ecore_wl2_egl_window_native_get(wl2_egl_window_);
delegate_->OnAcceleratedWidgetAvailable(
reinterpret_cast<uintptr_t>(egl_window));
+
+ if (type_ != PlatformWindowType::kWindow) {
+ ecore_wl2_window_type_set(wl_window_, GetEcoreWl2WindowType(type_));
+ ecore_wl2_window_position_set(wl_window_, bounds_.x(), bounds_.y());
+ }
#else
delegate_->OnAcceleratedWidgetAvailable(ecore_evas_window_get(ee_));
#endif
- if (type_ != PlatformWindowType::kWindow)
- return;
-
// Initialize efl event handler for main window
events_overlay_ = evas_object_rectangle_add(ecore_evas_get(ee_));
evas_object_color_set(events_overlay_, 0, 0, 0, 255);
InitializeEventHandler();
+ window_manager_->AddWindow(this, events_overlay_);
+
#if BUILDFLAG(IS_TIZEN_TV)
CreateMouseCursor();
#endif
- EflScreen::UpdateDisplayInfo(ee_);
+ if (type_ == PlatformWindowType::kWindow) {
+ EflScreen::UpdateDisplayInfo(ee_);
+ }
}
#if BUILDFLAG(IS_TIZEN_TV)
// Set activation true on window to capture key events.
delegate_->OnActivationChanged(true /*active*/);
- // Set focus active for a newly opened window.
- UpdateFocus(true);
-
efl_event_handler_ = std::make_unique<EflEventHandler>(this);
PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
}
InitializeEventHandler();
+ window_manager_->AddWindow(this, events_overlay_);
+
#if BUILDFLAG(IS_TIZEN)
// Create IMContextEfl only after event handler is instantiated, because
// content layer gets IMContextEfl through EflEventHandler.
--- /dev/null
+// Copyright (c) 2021 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/efl/efl_window_manager.h"
+
+#include "ui/ozone/platform/efl/efl_window.h"
+
+namespace ui {
+
+EflWindowManager::EflWindowManager() = default;
+EflWindowManager::~EflWindowManager() = default;
+
+void EflWindowManager::AddWindow(EflWindow* window, Evas_Object* eo) {
+ window_map_[eo] = window;
+}
+
+EflWindow* EflWindowManager::GetWindow(Evas_Object* eo) const {
+ auto it = window_map_.find(eo);
+ return it == window_map_.end() ? nullptr : it->second;
+}
+
+void EflWindowManager::RemoveWindow(Evas_Object* eo) {
+ auto* window = window_map_[eo];
+ DCHECK(window);
+ window_map_.erase(eo);
+}
+
+void EflWindowManager::UpdateWindowFocus(EflWindow* window, bool focused) {
+ for (const auto& item : window_map_) {
+ if (item.second != window) {
+ item.second->SetFocus(false);
+ }
+ }
+}
+
+std::vector<EflWindow*> EflWindowManager::GetAllOpenWindows() const {
+ std::vector<EflWindow*> all_windows;
+ for (const auto& item : window_map_) {
+ all_windows.push_back(item.second);
+ }
+ return all_windows;
+}
+
+void EflWindowManager::GrabLocatedEvents(EflWindow* window) {
+ DCHECK_NE(located_events_grabber_, window);
+ auto* old_grabber = located_events_grabber_;
+ located_events_grabber_ = window;
+ if (old_grabber) {
+ old_grabber->OnWindowLostCapture();
+ }
+}
+
+void EflWindowManager::UngrabLocatedEvents(EflWindow* window) {
+ DCHECK_EQ(located_events_grabber_, window);
+ auto* old_grabber = located_events_grabber_;
+ located_events_grabber_ = nullptr;
+ old_grabber->OnWindowLostCapture();
+}
+
+} // namespace ui
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_
-#define UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_
+#ifndef UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_H_
+#define UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_H_
+
+#include <Ecore_Evas.h>
#include "base/containers/flat_map.h"
-#include "ui/ozone/platform/efl/efl_window.h"
namespace ui {
+class EflWindow;
+
class EflWindowManager {
public:
- EflWindowManager() {}
- ~EflWindowManager() {}
+ EflWindowManager();
+ ~EflWindowManager();
EflWindowManager(const EflWindowManager&) = delete;
EflWindowManager& operator=(const EflWindowManager&) = delete;
- void AddWindow(EflWindow* window, Evas_Object* eo) {
- window_map_[eo] = window;
- }
-
- EflWindow* GetWindow(Evas_Object* eo) const {
- auto it = window_map_.find(eo);
- return it == window_map_.end() ? nullptr : it->second;
- }
-
- void RemoveWindow(Evas_Object* eo) {
- auto* window = window_map_[eo];
- DCHECK(window);
- window_map_.erase(eo);
- }
-
- void UpdateWindowFocus(EflWindow* window, bool focused) {
- for (const auto& item : window_map_) {
- if (item.second != window)
- item.second->SetFocus(false);
- }
- }
-
- std::vector<EflWindow*> GetAllOpenWindows() const {
- std::vector<EflWindow*> all_windows;
- for (const auto& item : window_map_)
- all_windows.push_back(item.second);
- return all_windows;
- }
+ void AddWindow(EflWindow* window, Evas_Object* eo);
+
+ EflWindow* GetWindow(Evas_Object* eo) const;
+
+ void RemoveWindow(Evas_Object* eo);
+
+ void UpdateWindowFocus(EflWindow* window, bool focused);
+
+ std::vector<EflWindow*> GetAllOpenWindows() const;
+
+ void GrabLocatedEvents(EflWindow* window);
+
+ void UngrabLocatedEvents(EflWindow* window);
+
+ EflWindow* located_events_grabber() const { return located_events_grabber_; }
private:
base::flat_map<Evas_Object*, EflWindow*> window_map_;
+ EflWindow* located_events_grabber_ = nullptr;
};
} // namespace ui
-#endif // UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_
+#endif // UI_OZONE_PLATFORM_EFL_EFL_WINDOW_MANAGER_H_