Merge "[Tizen] Fix the calculating logic for input region" into tizen_7.0
authorWonsik Jung <sidein@samsung.com>
Mon, 3 Apr 2023 10:03:48 +0000 (10:03 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 3 Apr 2023 10:03:48 +0000 (10:03 +0000)
1  2 
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp
dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h

@@@ -589,11 -589,8 +589,8 @@@ unsigned int Window::GetAuxiliaryHintId
  
  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)
@@@ -800,11 -797,6 +797,11 @@@ void Window::SetPositionSize(PositionSi
    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();
@@@ -1263,58 -1255,16 +1260,16 @@@ void Window::EnableFloatingMode(bool en
    mWindowBase->EnableFloatingMode(enable);
  }
  
- Rect<int> Window::RecalculateRect(const Rect<int>& rect)
- {
-   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;
- }
  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)
@@@ -332,11 -332,6 +332,11 @@@ public
    PositionSize GetPositionSize() const;
  
    /**
 +   * @copydoc Dali::Window::SetLayout()
 +   */
 +  void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan);
 +
 +  /**
     * @copydoc Dali::Window::GetRootLayer()
     */
    Dali::Layer GetRootLayer() const;
@@@ -608,20 -603,6 +608,6 @@@ private
     */
    bool IsOrientationAvailable(WindowOrientation orientation) const;
  
-   /**
-    * @brief Return the rect value to recalulate with the default system coordinates.
-    *
-    * Some native window APIs work the geometry value based on the default system coordinates.
-    * IncludeInputRegion() and ExcludeInputRegion() are one of them.
-    * When the window is rotated, current window's geometry already were set with the rotated angle.
-    * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
-    * the rect's area should be re-calcuated on the default system coordinates.
-    *
-    * @param[in] rect the window's current position and size with current window rotation angle.
-    * @return the re-calculated rect on the default system coordinates.
-    */
-   Rect<int> RecalculateRect(const Rect<int>& rect);
  private: // Dali::Internal::Adaptor::SceneHolder
    /**
     * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
@@@ -1844,12 -1844,6 +1844,12 @@@ void WindowBaseEcoreWl2::MoveResize(Pos
    ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, newPositionSize.x, newPositionSize.y, newPositionSize.width, newPositionSize.height);
  }
  
 +void WindowBaseEcoreWl2::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
 +{
 +  DALI_LOG_RELEASE_INFO("ecore_wl2_window_layout_set, numCols[%d], numRows[%d], column[%d], row[%d], colSpan[%d], rowSpan[%d]\n", numCols, numRows, column, row, colSpan, rowSpan);
 +  ecore_wl2_window_layout_set(mEcoreWindow, numCols, numRows, column, row, colSpan, rowSpan);
 +}
 +
  void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
  {
    ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
@@@ -2070,15 -2064,53 +2070,53 @@@ unsigned int WindowBaseEcoreWl2::GetAux
    return 0;
  }
  
+ Rect<int> WindowBaseEcoreWl2::RecalculateInputRect(const Rect<int>& rect)
+ {
+   Rect<int> newRect;
+   if(mWindowRotationAngle == 90)
+   {
+     newRect.x      = rect.y;
+     newRect.y      = mWindowPositionSize.height - (rect.x + rect.width);
+     newRect.width  = rect.height;
+     newRect.height = rect.width;
+   }
+   else if(mWindowRotationAngle == 180)
+   {
+     newRect.x      = mWindowPositionSize.width - (rect.x + rect.width);
+     newRect.y      = mWindowPositionSize.height - (rect.y + rect.height);
+     newRect.width  = rect.width;
+     newRect.height = rect.height;
+   }
+   else if(mWindowRotationAngle == 270)
+   {
+     newRect.x      = mWindowPositionSize.width - (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;
+ }
  void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
  {
-   DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
+   Rect<int> convertRegion = RecalculateInputRect(inputRegion);
    Eina_Rectangle rect;
-   rect.x = inputRegion.x;
-   rect.y = inputRegion.y;
-   rect.w = inputRegion.width;
-   rect.h = inputRegion.height;
+   rect.x = convertRegion.x;
+   rect.y = convertRegion.y;
+   rect.w = convertRegion.width;
+   rect.h = convertRegion.height;
  
+   DALI_LOG_RELEASE_INFO("%p, Set input rect (%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
    ecore_wl2_window_input_rect_set(mEcoreWindow, &rect);
    ecore_wl2_window_commit(mEcoreWindow, EINA_TRUE);
  }
@@@ -2887,11 -2919,13 +2925,13 @@@ bool WindowBaseEcoreWl2::IsFloatingMode
  
  void WindowBaseEcoreWl2::IncludeInputRegion(const Rect<int>& inputRegion)
  {
+   Rect<int> convertRegion = RecalculateInputRect(inputRegion);
    Eina_Rectangle rect;
-   rect.x = inputRegion.x;
-   rect.y = inputRegion.y;
-   rect.w = inputRegion.width;
-   rect.h = inputRegion.height;
+   rect.x = convertRegion.x;
+   rect.y = convertRegion.y;
+   rect.w = convertRegion.width;
+   rect.h = convertRegion.height;
  
    DALI_LOG_RELEASE_INFO("%p, Add input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
    ecore_wl2_window_input_rect_add(mEcoreWindow, &rect);
  
  void WindowBaseEcoreWl2::ExcludeInputRegion(const Rect<int>& inputRegion)
  {
+   Rect<int> convertRegion = RecalculateInputRect(inputRegion);
    Eina_Rectangle rect;
-   rect.x = inputRegion.x;
-   rect.y = inputRegion.y;
-   rect.w = inputRegion.width;
-   rect.h = inputRegion.height;
+   rect.x = convertRegion.x;
+   rect.y = convertRegion.y;
+   rect.w = convertRegion.width;
+   rect.h = convertRegion.height;
  
    DALI_LOG_RELEASE_INFO("%p, Subtract input_rect(%d, %d, %d x %d)\n", mEcoreWindow, rect.x, rect.y, rect.w, rect.h);
    ecore_wl2_window_input_rect_subtract(mEcoreWindow, &rect);
@@@ -273,11 -273,6 +273,11 @@@ public
     */
    void MoveResize(PositionSize positionSize) override;
  
 + /**
 +   * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
 +   */
 +  void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
 +
    /**
     * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
     */
@@@ -577,6 -572,21 +577,21 @@@ private
     */
    PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
  
+   /**
+    * @brief Return the rect value to recalulate with the default system coordinates.
+    *
+    * Some native window APIs work the geometry value based on the default system coordinates.
+    * IncludeInputRegion() and ExcludeInputRegion() are one of them.
+    * When the window is rotated, current window's geometry already were set with the rotated angle.
+    * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
+    * the rect's area should be re-calcuated on the default system coordinates.
+    *
+    * @param[in] rect the window's current position and size with current window rotation angle.
+    * @return the re-calculated rect on the default system coordinates.
+    */
+   Rect<int> RecalculateInputRect(const Rect<int>& rect);
  protected:
    // Undefined
    WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;