Add Window::SetLayout method
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / x11 / window-base-x.cpp
index 89232ab..c6868ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ namespace Adaptor
 {
 namespace
 {
-const std::string            DEFAULT_DEVICE_NAME     = "";
+const char*                  DEFAULT_DEVICE_NAME     = "";
 const Device::Class::Type    DEFAULT_DEVICE_CLASS    = Device::Class::NONE;
 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
 
@@ -53,6 +53,17 @@ Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false
 // Window Callbacks
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
+static bool EventWindowConfigureNotify(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
+{
+  WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
+  if(windowBase)
+  {
+    windowBase->OnConfigure(event);
+  }
+
+  return false;
+}
+
 static bool EventWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
 {
   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
@@ -259,9 +270,6 @@ WindowBaseX::~WindowBaseX()
   if(mOwnSurface)
   {
     XDestroyWindow(WindowSystem::GetImplementation().GetXDisplay(), mWindow);
-
-    /**** @todo Should not be destroyed here! ****/
-    WindowSystem::Shutdown();
   }
 }
 
@@ -273,9 +281,6 @@ void WindowBaseX::Initialize(PositionSize positionSize, Any surface, bool isTran
   // if the surface is empty, create a new one.
   if(surfaceId == 0)
   {
-    /**** @todo Should be created from somewhere else! ****/
-    WindowSystem::Initialize();
-
     // we own the surface about to created
     mOwnSurface = true;
     CreateWindow(positionSize, isTransparent);
@@ -326,6 +331,7 @@ void WindowBaseX::EnableDragAndDrop()
 void WindowBaseX::SetupEvents()
 {
   auto& windowSystem = WindowSystem::GetImplementation();
+  windowSystem.AddEventHandler(WindowSystemBase::Event::CONFIGURE_NOTIFY, EventWindowConfigureNotify, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::PROPERTY_NOTIFY, EventWindowPropertyChanged, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::DELETE_REQUEST, EventWindowDeleteRequest, this);
   windowSystem.AddEventHandler(WindowSystemBase::Event::FOCUS_IN, EventWindowFocusIn, this);
@@ -389,6 +395,22 @@ bool WindowBaseX::OnWindowPropertyChanged(void* data, WindowSystemBase::Event ty
   return handled;
 }
 
+void WindowBaseX::OnConfigure(WindowSystemBase::EventBase* event)
+{
+  auto configureEvent = static_cast<WindowSystemX::X11ConfigureNotifyEvent*>(event);
+  if(configureEvent->window == mWindow)
+  {
+    DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::OnConfigureNotify\n");
+    Dali::PositionSize positionSize;
+    positionSize.x      = configureEvent->x;
+    positionSize.y      = configureEvent->y;
+    positionSize.width  = configureEvent->width;
+    positionSize.height = configureEvent->height;
+    /// @note Can also get the window below this one if raise/lower was called.
+    mUpdatePositionSizeSignal.Emit(positionSize);
+  }
+}
+
 void WindowBaseX::OnDeleteRequest()
 {
   mDeleteRequestSignal.Emit();
@@ -636,6 +658,10 @@ void WindowBaseX::MoveResize(PositionSize positionSize)
   WindowSystem::GetImplementation().MoveResize(mWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
 }
 
+void WindowBaseX::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
+{
+}
+
 void WindowBaseX::SetClass(const std::string& name, const std::string& className)
 {
   WindowSystem::GetImplementation().SetClass(mWindow, name, className);
@@ -812,7 +838,7 @@ void WindowBaseX::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
   WindowSystem::GetImplementation().GetDPI(dpiHorizontal, dpiVertical);
 }
 
-int WindowBaseX::GetOrientation() const
+int WindowBaseX::GetWindowRotationAngle() const
 {
   return 0;
 }