[Tizen] Add InsetsChangedSignal to WindowBaseEcoreWl2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-impl.cpp
index 9175ca7..7e0a6ab 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.
@@ -93,6 +93,11 @@ Window::Window()
   mKeyboardRepeatSettingsChangedSignal(),
   mAuxiliaryMessageSignal(),
   mMovedSignal(),
+  mOrientationChangedSignal(),
+  mMouseInOutEventSignal(),
+  mMoveCompletedSignal(),
+  mResizeCompletedSignal(),
+  mInsetsChangedSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -117,7 +122,7 @@ Window::~Window()
     bridge->Emit(accessible, Accessibility::WindowEvent::DESTROY);
   }
 
-  if(mAdaptor)
+  if(DALI_LIKELY(mAdaptor))
   {
     mAdaptor->RemoveWindow(this);
   }
@@ -157,10 +162,15 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
   mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
   mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
+  mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
+  mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
+  mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
 
+  mWindowBase->InsetsChangedSignal().Connect(this, &Window::OnInsetsChanged);
+
   AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
 
   SetClass(name, className);
@@ -194,6 +204,16 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mNativeWindowId = mWindowBase->GetNativeWindowId();
 }
 
+void Window::SetRenderNotification(TriggerEventInterface* renderNotification)
+{
+  if(!mWindowSurface)
+  {
+    return;
+  }
+
+  mWindowSurface->SetRenderNotification(renderNotification);
+}
+
 void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
 {
   mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
@@ -588,11 +608,8 @@ unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
 
 void Window::SetInputRegion(const Rect<int>& inputRegion)
 {
-  Rect<int> convertRegion = RecalculateRect(inputRegion);
-
-  DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window (%p), WinId (%d), SetInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
-
-  mWindowBase->SetInputRegion(convertRegion);
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
+  mWindowBase->SetInputRegion(inputRegion);
 }
 
 void Window::SetType(WindowType type)
@@ -799,6 +816,11 @@ void Window::SetPositionSize(PositionSize positionSize)
   Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
 }
 
+void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
+{
+  mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
+}
+
 Dali::Layer Window::GetRootLayer() const
 {
   return mScene.GetRootLayer();
@@ -841,8 +863,11 @@ void Window::OnIconifyChanged(bool iconified)
       mVisibilityChangedSignal.Emit(handle, false);
       Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(handle);
 
-      WindowVisibilityObserver* observer(mAdaptor);
-      observer->OnWindowHidden();
+      if(DALI_LIKELY(mAdaptor))
+      {
+        WindowVisibilityObserver* observer(mAdaptor);
+        observer->OnWindowHidden();
+      }
     }
 
     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
@@ -857,8 +882,11 @@ void Window::OnIconifyChanged(bool iconified)
       mVisibilityChangedSignal.Emit(handle, true);
       Dali::Accessibility::Bridge::GetCurrentBridge()->WindowShown(handle);
 
-      WindowVisibilityObserver* observer(mAdaptor);
-      observer->OnWindowShown();
+      if(DALI_LIKELY(mAdaptor))
+      {
+        WindowVisibilityObserver* observer(mAdaptor);
+        observer->OnWindowShown();
+      }
     }
 
     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
@@ -894,8 +922,11 @@ void Window::OnOutputTransformed()
 
   SurfaceRotated(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height), mRotationAngle, mWindowBase->GetScreenRotationAngle());
 
-  mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
-  mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
+  if(DALI_LIKELY(mAdaptor))
+  {
+    mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
+    mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(positionSize.width, positionSize.height));
+  }
 }
 
 void Window::OnDeleteRequest()
@@ -917,7 +948,10 @@ void Window::OnKeyboardRepeatSettingsChanged()
 
 void Window::OnWindowRedrawRequest()
 {
-  mAdaptor->RenderOnce();
+  if(DALI_LIKELY(mAdaptor))
+  {
+    mAdaptor->RenderOnce();
+  }
 }
 
 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
@@ -963,16 +997,25 @@ void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
 
     SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
 
-    mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
+    if(DALI_LIKELY(mAdaptor))
+    {
+      mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
+    }
 
     DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resized signal emit [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
     mResizeSignal.Emit(handle, newSize);
-    mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
+    if(DALI_LIKELY(mAdaptor))
+    {
+      mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
+    }
   }
 
   mSurface->SetFullSwapNextFrame();
 
-  Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
+  if(DALI_LIKELY(mScene))
+  {
+    Dali::Accessibility::Accessible::Get(mScene.GetRootLayer())->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
+  }
 }
 
 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
@@ -992,6 +1035,13 @@ void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
   FeedKeyEvent(keyEvent);
 }
 
+void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
+{
+  Dali::Window handle(this);
+
+  mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
+}
+
 void Window::OnRotation(const RotationEvent& rotation)
 {
   PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
@@ -1010,12 +1060,19 @@ void Window::OnRotation(const RotationEvent& rotation)
 
   SurfaceRotated(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight), mRotationAngle, mWindowBase->GetScreenRotationAngle());
 
-  mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
+  if(DALI_LIKELY(mAdaptor))
+  {
+    mAdaptor->SurfaceResizePrepare(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
+  }
 
   Dali::Window handle(this);
   mResizeSignal.Emit(handle, Dali::Window::WindowSize(mWindowWidth, mWindowHeight));
+  mOrientationChangedSignal.Emit(handle, GetCurrentOrientation());
 
-  mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
+  if(DALI_LIKELY(mAdaptor))
+  {
+    mAdaptor->SurfaceResizeComplete(mSurface.get(), Adaptor::SurfaceSize(mWindowWidth, mWindowHeight));
+  }
 }
 
 void Window::OnRotationFinished()
@@ -1047,6 +1104,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();
@@ -1076,6 +1138,18 @@ void Window::OnAccessibilityDisabled()
   bridge->RemoveTopLevelWindow(accessible);
 }
 
+void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
+{
+  Dali::Window handle(this);
+  mMoveCompletedSignal.Emit(handle, position);
+}
+
+void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
+{
+  Dali::Window handle(this);
+  mResizeCompletedSignal.Emit(handle, size);
+}
+
 Vector2 Window::RecalculatePosition(const Vector2& position)
 {
   Vector2 convertedPosition;
@@ -1229,58 +1303,21 @@ void Window::EnableFloatingMode(bool enable)
   mWindowBase->EnableFloatingMode(enable);
 }
 
-Rect<int> Window::RecalculateRect(const Rect<int>& rect)
+bool Window::IsFloatingModeEnabled()
 {
-  Rect<int> newRect;
-  int       screenWidth, screenHeight;
-
-  WindowSystem::GetScreenSize(screenWidth, screenHeight);
-
-  if(mRotationAngle == 90)
-  {
-    newRect.x      = rect.y;
-    newRect.y      = screenHeight - (rect.x + rect.width);
-    newRect.width  = rect.height;
-    newRect.height = rect.width;
-  }
-  else if(mRotationAngle == 180)
-  {
-    newRect.x      = screenWidth - (rect.x + rect.width);
-    newRect.y      = screenHeight - (rect.y + rect.height);
-    newRect.width  = rect.width;
-    newRect.height = rect.height;
-  }
-  else if(mRotationAngle == 270)
-  {
-    newRect.x      = screenWidth - (rect.y + rect.height);
-    newRect.y      = rect.x;
-    newRect.width  = rect.height;
-    newRect.height = rect.width;
-  }
-  else
-  {
-    newRect.x      = rect.x;
-    newRect.y      = rect.y;
-    newRect.width  = rect.width;
-    newRect.height = rect.height;
-  }
-  return newRect;
+  return mWindowBase->IsFloatingModeEnabled();
 }
 
 void Window::IncludeInputRegion(const Rect<int>& inputRegion)
 {
-  Rect<int> convertRegion = RecalculateRect(inputRegion);
-
-  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IncludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
-  mWindowBase->IncludeInputRegion(convertRegion);
+  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);
+  mWindowBase->IncludeInputRegion(inputRegion);
 }
 
 void Window::ExcludeInputRegion(const Rect<int>& inputRegion)
 {
-  Rect<int> convertRegion = RecalculateRect(inputRegion);
-
-  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, RecalculateRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, convertRegion.x, convertRegion.y, convertRegion.width, convertRegion.height);
-  mWindowBase->ExcludeInputRegion(convertRegion);
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), ExcludeInputRegion, (%d,%d), (%d x %d)\n", this, mNativeWindowId, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
+  mWindowBase->ExcludeInputRegion(inputRegion);
 }
 
 void Window::SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)