Merge "Supports the key event repeat and delay for each way." into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index 9d6fcee..ae3a117 100644 (file)
@@ -28,8 +28,6 @@
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/adaptor-framework/window-enumerations.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/rendering/frame-buffer.h>
 #include <thread>
 
@@ -60,17 +58,17 @@ Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "L
 #endif
 } // unnamed namespace
 
-Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
+Window* Window::New(const std::string& name, const std::string& className, const WindowData& windowData)
 {
   Any surface;
-  return Window::New(surface, positionSize, name, className, type, isTransparent);
+  return Window::New(surface, name, className, windowData);
 }
 
-Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, Dali::WindowType type, bool isTransparent)
+Window* Window::New(Any surface, const std::string& name, const std::string& className, const WindowData& windowData)
 {
   Window* window         = new Window();
-  window->mIsTransparent = isTransparent;
-  window->Initialize(surface, positionSize, name, className, type);
+  window->mIsTransparent = windowData.GetTransparency();
+  window->Initialize(surface, windowData.GetPositionSize(), name, className, windowData.GetWindowType());
   return window;
 }
 
@@ -94,8 +92,10 @@ Window::Window()
   mMovedSignal(),
   mOrientationChangedSignal(),
   mMouseInOutEventSignal(),
+  mMouseRelativeEventSignal(),
   mMoveCompletedSignal(),
   mResizeCompletedSignal(),
+  mInsetsChangedSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -105,7 +105,8 @@ Window::Window()
   mOpaqueState(false),
   mWindowRotationAcknowledgement(false),
   mFocused(false),
-  mIsWindowRotating(false)
+  mIsWindowRotating(false),
+  mIsEnabledUserGeometry(false)
 {
 }
 
@@ -163,13 +164,14 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
   mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
   mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
+  mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
   mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
   mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
 
-  AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
+  mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
 
   SetClass(name, className);
 
@@ -187,15 +189,21 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
     mOrientationMode = Internal::Adaptor::Window::OrientationMode::PORTRAIT;
   }
 
-  if(positionSize.width <= 0 || positionSize.height <= 0)
+  mWindowWidth  = positionSize.width;
+  mWindowHeight = positionSize.height;
+
+  bool isSetWithScreenSize = false;
+  if(mWindowWidth <= 0 || mWindowHeight <= 0)
   {
-    mWindowWidth  = screenWidth;
-    mWindowHeight = screenHeight;
+    mWindowWidth        = screenWidth;
+    mWindowHeight       = screenHeight;
+    isSetWithScreenSize = true;
+    DALI_LOG_RELEASE_INFO("Window size is set with screen size(%d x %d)\n", mWindowWidth, mWindowHeight);
   }
-  else
+
+  if(isSetWithScreenSize == false || positionSize.x != 0 || positionSize.y != 0)
   {
-    mWindowWidth  = positionSize.width;
-    mWindowHeight = positionSize.height;
+    SetUserGeometryPolicy();
   }
 
   // For Debugging
@@ -326,9 +334,19 @@ Dali::Layer Window::GetLayer(uint32_t depth) const
   return mScene.GetLayer(depth);
 }
 
-Dali::RenderTaskList Window::GetRenderTaskList() const
+void Window::KeepRendering(float durationSeconds)
 {
-  return mScene.GetRenderTaskList();
+  mScene.KeepRendering(durationSeconds);
+}
+
+void Window::SetPartialUpdateEnabled(bool enabled)
+{
+  mScene.SetPartialUpdateEnabled(enabled);
+}
+
+bool Window::IsPartialUpdateEnabled() const
+{
+  return mScene.IsPartialUpdateEnabled();
 }
 
 std::string Window::GetNativeResourceId() const
@@ -696,6 +714,8 @@ void Window::SetSize(Dali::Window::WindowSize size)
   newRect.width  = size.GetWidth();
   newRect.height = size.GetHeight();
 
+  SetUserGeometryPolicy();
+
   // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
   if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
   {
@@ -734,6 +754,8 @@ void Window::SetPosition(Dali::Window::WindowPosition position)
   int32_t      newX    = position.GetX();
   int32_t      newY    = position.GetY();
 
+  SetUserGeometryPolicy();
+
   mWindowSurface->Move(PositionSize(newX, newY, oldRect.width, oldRect.height));
 
   if((oldRect.x != newX) || (oldRect.y != newY))
@@ -772,6 +794,8 @@ void Window::SetPositionSize(PositionSize positionSize)
   PositionSize oldRect = GetPositionSize();
   Dali::Window handle(this);
 
+  SetUserGeometryPolicy();
+
   if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
   {
     moved = true;
@@ -820,6 +844,7 @@ void Window::SetPositionSize(PositionSize positionSize)
 
 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
 {
+  SetUserGeometryPolicy();
   mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
 }
 
@@ -1056,6 +1081,13 @@ void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseIn
   mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
 }
 
+void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& MouseRelativeEvent)
+{
+  Dali::Window handle(this);
+
+  mMouseRelativeEventSignal.Emit(handle, MouseRelativeEvent);
+}
+
 void Window::OnRotation(const RotationEvent& rotation)
 {
   PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
@@ -1112,6 +1144,11 @@ void Window::OnAuxiliaryMessage(const std::string& key, const std::string& value
   mAuxiliaryMessageSignal.Emit(key, value, options);
 }
 
+void Window::OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets)
+{
+  mInsetsChangedSignal.Emit(partType, partState, insets);
+}
+
 void Window::OnAccessibilityEnabled()
 {
   auto bridge     = Accessibility::Bridge::GetCurrentBridge();
@@ -1293,11 +1330,13 @@ int32_t Window::GetNativeId() const
 
 void Window::RequestMoveToServer()
 {
+  SetUserGeometryPolicy();
   mWindowBase->RequestMoveToServer();
 }
 
 void Window::RequestResizeToServer(WindowResizeDirection direction)
 {
+  SetUserGeometryPolicy();
   mWindowBase->RequestResizeToServer(direction);
 }
 
@@ -1306,6 +1345,11 @@ void Window::EnableFloatingMode(bool enable)
   mWindowBase->EnableFloatingMode(enable);
 }
 
+bool Window::IsFloatingModeEnabled()
+{
+  return mWindowBase->IsFloatingModeEnabled();
+}
+
 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
 {
   DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
@@ -1349,6 +1393,43 @@ const Dali::TouchEvent& Window::GetLastTouchEvent() const
   return mLastTouchEvent;
 }
 
+void Window::SetUserGeometryPolicy()
+{
+  if(mIsEnabledUserGeometry == true)
+  {
+    return;
+  }
+
+  mIsEnabledUserGeometry = true;
+  AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), window user.geometry is changed\n", this, mNativeWindowId);
+}
+
+bool Window::PointerConstraintsLock()
+{
+  return mWindowBase->PointerConstraintsLock();
+}
+
+bool Window::PointerConstraintsUnlock()
+{
+  return mWindowBase->PointerConstraintsUnlock();
+}
+
+void Window::LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height)
+{
+  mWindowBase->LockedPointerRegionSet(x, y, width, height);
+}
+
+void Window::LockedPointerCursorPositionHintSet(int32_t x, int32_t y)
+{
+  mWindowBase->LockedPointerCursorPositionHintSet(x, y);
+}
+
+bool Window::PointerWarp(int32_t x, int32_t y)
+{
+  return mWindowBase->PointerWarp(x, y);
+}
+
 } // namespace Adaptor
 
 } // namespace Internal