Fix the bug about window resize/move completed signal. 08/324708/7
authorWonsik Jung <sidein@samsung.com>
Fri, 23 May 2025 08:57:20 +0000 (17:57 +0900)
committerWonsik Jung <sidein@samsung.com>
Mon, 26 May 2025 08:54:42 +0000 (17:54 +0900)
Fix the bug about window resize/move completed signal.
When the window resize/move completed signal work,
application can not get the changed window geometry in the related signal callbacks.
This patch is to fix the related bug.

Change-Id: I3d0a6cc9eb7a97ee92a17d63b68512d651959e8f

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

index 0a81983ebd095b4739efb78573907d1ddd6bb9fb..5d3e22ef710153e41ef4e4c356f82aa78f4db8e3 100644 (file)
@@ -820,64 +820,11 @@ PositionSize Window::GetPositionSize() const
 
 void Window::SetPositionSize(PositionSize positionSize)
 {
-  bool moved  = false;
-  bool resize = false;
-
-  PositionSize oldRect = GetPositionSize();
-  Dali::Window handle(this);
-
   SetUserGeometryPolicy();
 
-  if((oldRect.x != positionSize.x) || (oldRect.y != positionSize.y))
-  {
-    moved = true;
-  }
-
-  if((oldRect.width != positionSize.width) || (oldRect.height != positionSize.height))
-  {
-    resize = true;
-  }
-
-  if(moved || resize)
-  {
-    mWindowSurface->MoveResize(positionSize);
-  }
-
-  // When window is moved, emit Moved Signal
-  if(moved)
-  {
-    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, positionSize.x, positionSize.y);
-    Dali::Window::WindowPosition position(positionSize.x, positionSize.y);
-    mMovedSignal.Emit(handle, position);
-  }
-
-  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
-  if(resize)
-  {
-    Uint16Pair newSize(positionSize.width, positionSize.height);
-
-    mWindowWidth  = positionSize.width;
-    mWindowHeight = positionSize.height;
-
-    SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
-
-    mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
-
-    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Resize signal emit [%d x %d]\n", this, mNativeWindowId, positionSize.width, positionSize.height);
-
-    mResizeSignal.Emit(handle, newSize);
-    mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
-  }
-
-  if((moved || resize) && Dali::Accessibility::IsUp())
-  {
-    if(auto accessible = dynamic_cast<Accessibility::ActorAccessible*>(Accessibility::Accessible::Get(mScene.GetRootLayer())))
-    {
-      accessible->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
-    }
-  }
-
-  mSurface->SetFullSwapNextFrame();
+  // It is asked by application to change window position and size.
+  // The related API is called to ask to display server in the backend.
+  UpdatePositionSize(positionSize, true);
 }
 
 void Window::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
@@ -1079,63 +1026,9 @@ void Window::OnWindowRedrawRequest()
 
 void Window::OnUpdatePositionSize(Dali::PositionSize& positionSize)
 {
-  bool moved  = false;
-  bool resize = false;
-
-  Dali::Window handle(this);
-
-  PositionSize oldRect = GetPositionSize();
-  PositionSize newRect = positionSize;
-
-  if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
-  {
-    moved = true;
-  }
-
-  if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
-  {
-    resize = true;
-  }
-
-  if(moved || resize)
-  {
-    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), position or size is updated by server , (%d, %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.x, newRect.y, newRect.width, newRect.height);
-    mWindowSurface->UpdatePositionSize(positionSize);
-  }
-
-  if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
-  {
-    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
-    Dali::Window::WindowPosition position(newRect.x, newRect.y);
-    mMovedSignal.Emit(handle, position);
-  }
-
-  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
-  if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
-  {
-    Uint16Pair newSize(newRect.width, newRect.height);
-
-    mWindowWidth  = newRect.width;
-    mWindowHeight = newRect.height;
-
-    SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
-
-    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((moved || resize) && Dali::Accessibility::IsUp())
-  {
-    if(auto accessible = dynamic_cast<Accessibility::ActorAccessible*>(Accessibility::Accessible::Get(mScene.GetRootLayer())))
-    {
-      accessible->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
-    }
-  }
-
-  mSurface->SetFullSwapNextFrame();
+  // It is from configure notification event, window move/resize signal will be emit.
+  // Just Update position size in window render surface without emit move/resize signal.
+  UpdatePositionSize(positionSize, false);
 }
 
 void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
@@ -1318,12 +1211,36 @@ bool Window::OnAccessibilityInterceptKeyEvent(const Dali::KeyEvent& keyEvent)
 void Window::OnMoveCompleted(Dali::Window::WindowPosition& position)
 {
   Dali::Window handle(this);
+
+  PositionSize positionSize = GetPositionSize();
+  positionSize.x = position.GetX();
+  positionSize.y = position.GetY();
+
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Window move completed, (%d, %d)\n",  this, mNativeWindowId, positionSize.x, positionSize.y);
+
+  // It is from window move completed event. This event is generated by displayer server
+  // Window move signal is emitted, too.
+  // Just Update position size in window render surface without emit move/resize signal.
+  UpdatePositionSize(positionSize, false);
+
   mMoveCompletedSignal.Emit(handle, position);
 }
 
 void Window::OnResizeCompleted(Dali::Window::WindowSize& size)
 {
   Dali::Window handle(this);
+
+  PositionSize positionSize = GetPositionSize();
+  positionSize.width = size.GetWidth();
+  positionSize.height = size.GetHeight();
+
+  DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Window resize completed, (%d x %d)\n",  this, mNativeWindowId, positionSize.width, positionSize.height);
+
+  // It is from window resized completed event. This event is generated by displayer server.
+  // Window resize signal is emitted, too.
+  // Just Update position size in window render surface without emit move/resize signal.
+  UpdatePositionSize(positionSize, false);
+
   mResizeCompletedSignal.Emit(handle, size);
 }
 
@@ -1683,6 +1600,77 @@ int Window::GetCurrentScreenRotationAngle() const
   return mWindowBase->GetScreenRotationAngle();
 }
 
+void Window::UpdatePositionSize(Dali::PositionSize& positionSize, bool requestChangeGeometry)
+{
+  bool moved  = false;
+  bool resize = false;
+
+  Dali::Window handle(this);
+
+  PositionSize oldRect = GetPositionSize();
+  PositionSize newRect = positionSize;
+
+  if((oldRect.x != newRect.x) || (oldRect.y != newRect.y))
+  {
+    moved = true;
+  }
+
+  if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
+  {
+    resize = true;
+  }
+
+  if(moved || resize)
+  {
+    if(requestChangeGeometry)
+    {
+      DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), position or size is updated by Application , (%d, %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.x, newRect.y, newRect.width, newRect.height);
+      mWindowSurface->MoveResize(positionSize);
+    }
+    else
+    {
+      DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), current angle (%d), position or size is updated by server , (%d, %d) [%d x %d]\n", this, mNativeWindowId, mRotationAngle, newRect.x, newRect.y, newRect.width, newRect.height);
+      mWindowSurface->UpdatePositionSize(positionSize);
+    }
+  }
+
+  if(moved)
+  {
+    DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Moved signal emit (%d, %d)\n", this, mNativeWindowId, newRect.x, newRect.y);
+    Dali::Window::WindowPosition position(newRect.x, newRect.y);
+    mMovedSignal.Emit(handle, position);
+  }
+
+  // When surface size is updated, inform adaptor of resizing and emit ResizeSignal
+  if(resize)
+  {
+    Uint16Pair newSize(newRect.width, newRect.height);
+
+    mWindowWidth  = newRect.width;
+    mWindowHeight = newRect.height;
+
+    SurfaceResized(static_cast<float>(mWindowWidth), static_cast<float>(mWindowHeight));
+
+    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((moved || resize) && Dali::Accessibility::IsUp())
+  {
+    if(auto accessible = dynamic_cast<Accessibility::ActorAccessible*>(Accessibility::Accessible::Get(mScene.GetRootLayer())))
+    {
+      accessible->EmitBoundsChanged(Dali::Rect<>(positionSize.x, positionSize.y, positionSize.width, positionSize.height));
+    }
+  }
+
+  mSurface->SetFullSwapNextFrame();
+}
+
+
 } // namespace Adaptor
 
 } // namespace Internal
index 944fbbbdadb391f8608dfbc0721044bc6f770e80..bb7311274f689cf61f3f5919281b4b29d7217935 100644 (file)
@@ -866,6 +866,24 @@ private:
    */
   void OnInsetsChanged(WindowInsetsPartType partType, WindowInsetsPartState partState, const Extents& insets);
 
+  /**
+   * @brief Window's position and size are updated.
+   * It is called when window's geometry is changed by display server or client.
+   *
+   * By server, the related events are window configure notification, window move completed and window resize completed event.
+   * When window configure notification event is emitted, window resize and move signals are emitted to application.
+   *
+   * When window move or resize completed event is emitted, window move or resize signal is emitted to application, too.
+   *
+   * By client, application calls SetPositionSize function.
+   * It means application requests to change window's geometry to display server.
+   * Window resize and move signals are emitted to application.
+   *
+   * @param[in] positionSize the updated window's position and size.
+   * @param[in] requestChangeGeometry the flag of whether requests to change window geometry to display server or just updating local geometry information.
+   */
+  void UpdatePositionSize(Dali::PositionSize& positionSize, bool requestChangeGeometry);
+
 private: // Dali::Internal::Adaptor::SceneHolder
   /**
    * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
index 0d94b239b1df29fac897154e61e45cadf608a401..f806f82d8adb8e8f939150ed0e36ae6c879530d5 100644 (file)
@@ -1936,6 +1936,9 @@ void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
     Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
     Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
     Dali::Int32Pair    newPosition(newPositionSize.x, newPositionSize.y);
+
+    mWindowPositionSize.x = orgPositionSize.x;
+    mWindowPositionSize.y = orgPositionSize.y;
     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnMoveCompleted, window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
     mMoveCompletedSignal.Emit(newPosition);
   }
@@ -1949,6 +1952,9 @@ void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
     Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
     Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
     Dali::Uint16Pair   newSize(newPositionSize.width, newPositionSize.height);
+
+    mWindowPositionSize.width = orgPositionSize.width;
+    mWindowPositionSize.height = orgPositionSize.height;
     DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnResizeCompleted, window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
     mResizeCompletedSignal.Emit(newSize);
   }