Merge "Add window move/resize completed signal" into devel/master
authorWonsik Jung <sidein@samsung.com>
Wed, 17 May 2023 03:58:36 +0000 (03:58 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 17 May 2023 03:58:36 +0000 (03:58 +0000)
automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/window-system/common/window-base.cpp
dali/internal/window-system/common/window-base.h
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

index b0d2bcf..f224d97 100644 (file)
@@ -1607,3 +1607,33 @@ int UtcDaliWindowMouseInOutSignalNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliWindowMoveCompletedSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::MoveCompletedSignal(instance);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliWindowResizeCompletedSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::ResizeCompletedSignal(instance);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
index 7021d3a..897ea9f 100644 (file)
@@ -121,6 +121,16 @@ OrientationChangedSignalType& OrientationChangedSignal(Window window)
   return GetImplementation(window).OrientationChangedSignal();
 }
 
+MoveCompletedSignalType& MoveCompletedSignal(Window window)
+{
+  return GetImplementation(window).MoveCompletedSignal();
+}
+
+ResizeCompletedSignalType& ResizeCompletedSignal(Window window)
+{
+  return GetImplementation(window).ResizeCompletedSignal();
+}
+
 void SetParent(Window window, Window parent)
 {
   GetImplementation(window).SetParent(parent);
index 94a3b30..9cfaa8f 100644 (file)
@@ -50,6 +50,8 @@ typedef Signal<bool(const KeyEvent&)>
 typedef Signal<void(Window, Dali::Window::WindowPosition)>                           MovedSignalType;                         ///< Window Moved signal type
 typedef Signal<void(Window, Dali::WindowOrientation)>                                OrientationChangedSignalType;            ///< Window orientation changed signal type
 typedef Signal<void(Window, const Dali::DevelWindow::MouseInOutEvent&)>              MouseInOutEventSignalType;               ///< MouseInOutEvent signal type
+typedef Signal<void(Window, Dali::Window::WindowPosition)>                           MoveCompletedSignalType;                 ///< Window Moved by Server signal type
+typedef Signal<void(Window, Dali::Window::WindowSize)>                               ResizeCompletedSignalType;               ///< Window Resized by Server signal type
 
 /**
  * @brief Creates an initialized handle to a new Window.
@@ -574,6 +576,40 @@ DALI_ADAPTOR_API OrientationChangedSignalType& OrientationChangedSignal(Window w
  */
 DALI_ADAPTOR_API MouseInOutEventSignalType& MouseInOutEventSignal(Window window);
 
+/**
+ * @brief This signal is emitted when window has been moved by the display server.
+ * To make the window move by display server, RequestMoveToServer() should be called.
+ * After the moving job is completed, this function will be called.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
+ * @endcode
+ * The parameters are the moved x and y coordinates.
+ * and window means this signal was called from what window
+ *
+ * @param[in] window The window instance.
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API MoveCompletedSignalType& MoveCompletedSignal(Window window);
+
+/**
+ * @brief This signal is emitted when window has been resized by the display server.
+ * To make the window move by display server, RequestResizeToServer() should be called.
+ * After the resizing job is completed, this function will be called.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Window window, Dali::Window::WindowPosition position );
+ * @endcode
+ * The parameters are the resized width and height coordinates.
+ * and window means this signal was called from what window
+ *
+ * @param[in] window The window instance.
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API ResizeCompletedSignalType& ResizeCompletedSignal(Window window);
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 9882b0d..a0a89dc 100644 (file)
@@ -42,7 +42,9 @@ WindowBase::WindowBase()
   mKeyboardRepeatSettingsChangedSignal(),
   mUpdatePositionSizeSignal(),
   mAuxiliaryMessageSignal(),
-  mMouseInOutEventSignal()
+  mMouseInOutEventSignal(),
+  mMoveCompletedSignal(),
+  mResizeCompletedSignal()
 {
 }
 
@@ -145,6 +147,16 @@ WindowBase::MouseInOutEventSignalType& WindowBase::MouseInOutEventSignal()
   return mMouseInOutEventSignal;
 }
 
+WindowBase::MoveCompletedSignalType& WindowBase::MoveCompletedSignal()
+{
+  return mMoveCompletedSignal;
+}
+
+WindowBase::ResizeCompletedSignalType& WindowBase::ResizeCompletedSignal()
+{
+  return mResizeCompletedSignal;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 6cb6819..699461a 100644 (file)
@@ -77,6 +77,8 @@ public:
   typedef Signal<void(Dali::PositionSize&)>                                            UpdatePositionSizeType;
   typedef Signal<void(const std::string&, const std::string&, const Property::Array&)> AuxiliaryMessageSignalType;
   typedef Signal<void(const Dali::DevelWindow::MouseInOutEvent&)>                      MouseInOutEventSignalType;
+  typedef Signal<void(Dali::Int32Pair&)>                                               MoveCompletedSignalType;
+  typedef Signal<void(Dali::Uint16Pair&)>                                              ResizeCompletedSignalType;
 
   // Input events
   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
@@ -546,7 +548,8 @@ public:
   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
 
   /**
-   * @brief This signal is emitted when the window is resized or moved by display server.
+   * @brief This signal is emitted when the window's geometry data is changed by display server or client.
+   * It is based on configure noification event.
    */
   UpdatePositionSizeType& UpdatePositionSizeSignal();
 
@@ -560,6 +563,20 @@ public:
    */
   MouseInOutEventSignalType& MouseInOutEventSignal();
 
+  /**
+   * @brief This signal is emitted when window has been moved by then display server.
+   * To be moved the window by display server, RequestMoveToServer() should be called.
+   * After the moving job is finished, this function will be called.
+   */
+  MoveCompletedSignalType& MoveCompletedSignal();
+
+  /**
+   * @brief This signal is emitted when window has been resized by then display server.
+   * To be resized the window by display server, RequestResizeToServer() should be called.
+   * After the resizing job is finished, this function will be called.
+   */
+  ResizeCompletedSignalType& ResizeCompletedSignal();
+
 protected:
   // Undefined
   WindowBase(const WindowBase&) = delete;
@@ -587,6 +604,8 @@ protected:
   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
   MouseInOutEventSignalType               mMouseInOutEventSignal;
+  MoveCompletedSignalType                 mMoveCompletedSignal;
+  ResizeCompletedSignalType               mResizeCompletedSignal;
 };
 
 } // namespace Adaptor
index 1afa98e..9d6fcee 100644 (file)
@@ -94,6 +94,8 @@ Window::Window()
   mMovedSignal(),
   mOrientationChangedSignal(),
   mMouseInOutEventSignal(),
+  mMoveCompletedSignal(),
+  mResizeCompletedSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -161,6 +163,8 @@ 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->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
+  mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
@@ -198,7 +202,7 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mNativeWindowId = mWindowBase->GetNativeWindowId();
 }
 
-void Window::SetRenderNotification(TriggerEventInterface *renderNotification)
+void Window::SetRenderNotification(TriggerEventInterfacerenderNotification)
 {
   if(!mWindowSurface)
   {
@@ -816,7 +820,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)
 {
-    mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
+  mWindowBase->SetLayout(numCols, numRows, column, row, colSpan, rowSpan);
 }
 
 Dali::Layer Window::GetRootLayer() const
@@ -1137,6 +1141,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;
index 35d96c5..849e540 100644 (file)
@@ -71,6 +71,8 @@ public:
   typedef Dali::DevelWindow::MovedSignalType                         MovedSignalType;
   typedef Dali::DevelWindow::OrientationChangedSignalType            OrientationChangedSignalType;
   typedef Dali::DevelWindow::MouseInOutEventSignalType               MouseInOutEventSignalType;
+  typedef Dali::DevelWindow::MoveCompletedSignalType                 MoveCompletedSignalType;
+  typedef Dali::DevelWindow::ResizeCompletedSignalType               ResizeCompletedSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
@@ -566,7 +568,8 @@ private:
   void OnWindowRedrawRequest();
 
   /**
-   * @brief Called when the window is resized or moved by display server.
+   * @brief Called when the window's geometry data is changed by display server or client.
+   * It is based on configure noification event.
    *
    * @param[in] positionSize the updated window's position and size.
    */
@@ -609,6 +612,20 @@ private:
   void OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent);
 
   /**
+   * @brief Called when the window is moved by display server.
+   *
+   * @param[in] position the moved window's position.
+   */
+  void OnMoveCompleted(Dali::Window::WindowPosition& position);
+
+  /**
+   * @brief Called when the window is resized by display server.
+   *
+   * @param[in] positionSize the resized window's size.
+   */
+  void OnResizeCompleted(Dali::Window::WindowSize& size);
+
+  /**
    * @brief Set available orientation to window base.
    */
   void SetAvailableAnlges(const std::vector<int>& angles);
@@ -772,6 +789,22 @@ public: // Signals
     return mMouseInOutEventSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::MoveCompletedSignal()
+   */
+  MoveCompletedSignalType& MoveCompletedSignal()
+  {
+    return mMoveCompletedSignal;
+  }
+
+  /**
+   * @copydoc Dali::DevelWindow::ResizeCompletedSignal()
+   */
+  ResizeCompletedSignalType& ResizeCompletedSignal()
+  {
+    return mResizeCompletedSignal;
+  }
+
 private:
   WindowRenderSurface* mWindowSurface; ///< The window rendering surface
   WindowBase*          mWindowBase;
@@ -783,10 +816,10 @@ private:
   std::vector<int> mAvailableAngles;
   int              mPreferredAngle;
 
-  int mRotationAngle;  ///< The angle of the rotation
-  int mWindowWidth;    ///< The width of the window
-  int mWindowHeight;   ///< The height of the window
-  int mNativeWindowId; ///< The Native Window Id
+  int mRotationAngle;               ///< The angle of the rotation
+  int mWindowWidth;                 ///< The width of the window
+  int mWindowHeight;                ///< The height of the window
+  int mNativeWindowId;              ///< The Native Window Id
 
   EventHandlerPtr mEventHandler;    ///< The window events handler
   OrientationMode mOrientationMode; ///< The physical screen mode is portrait or landscape
@@ -803,6 +836,8 @@ private:
   MovedSignalType                         mMovedSignal;
   OrientationChangedSignalType            mOrientationChangedSignal;
   MouseInOutEventSignalType               mMouseInOutEventSignal;
+  MoveCompletedSignalType                 mMoveCompletedSignal;
+  ResizeCompletedSignalType               mResizeCompletedSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index c1c1283..812ecfe 100644 (file)
@@ -716,6 +716,29 @@ static Eina_Bool EcoreEventWindowAuxiliaryMessage(void* data, int type, void* ev
   return ECORE_CALLBACK_RENEW;
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// Window is Moved/Resized By Server Callbacks
+/////////////////////////////////////////////////////////////////////////////////////////////////
+static Eina_Bool EcoreEventWindowMoveCompleted(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnMoveCompleted(event);
+  }
+  return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool EcoreEventWindowResizeCompleted(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnResizeCompleted(event);
+  }
+  return ECORE_CALLBACK_RENEW;
+}
+
 static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
 {
   WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
@@ -962,6 +985,10 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   vconf_notify_key_changed_for_ui_thread(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
 #endif
 
+  // Register Window is moved and resized done event.
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
+
   Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
   mDisplay                   = ecore_wl2_display_get(display);
 
@@ -1551,6 +1578,32 @@ void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
   }
 }
 
+void WindowBaseEcoreWl2::OnMoveCompleted(void* event)
+{
+  Ecore_Wl2_Event_Window_Interactive_Move_Done* movedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Move_Done*>(event);
+  if(movedDoneEvent)
+  {
+    Dali::PositionSize orgPositionSize(movedDoneEvent->x, movedDoneEvent->y, movedDoneEvent->w, movedDoneEvent->h);
+    Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
+    Dali::Int32Pair    newPosition(newPositionSize.x, newPositionSize.y);
+    DALI_LOG_RELEASE_INFO("window(%p) has been moved by server[%d, %d]\n", mEcoreWindow, newPositionSize.x, newPositionSize.y);
+    mMoveCompletedSignal.Emit(newPosition);
+  }
+}
+
+void WindowBaseEcoreWl2::OnResizeCompleted(void* event)
+{
+  Ecore_Wl2_Event_Window_Interactive_Resize_Done* resizedDoneEvent = static_cast<Ecore_Wl2_Event_Window_Interactive_Resize_Done*>(event);
+  if(resizedDoneEvent)
+  {
+    Dali::PositionSize orgPositionSize(resizedDoneEvent->x, resizedDoneEvent->y, resizedDoneEvent->w, resizedDoneEvent->h);
+    Dali::PositionSize newPositionSize = RecalculatePositionSizeToCurrentOrientation(orgPositionSize);
+    Dali::Uint16Pair   newSize(newPositionSize.width, newPositionSize.height);
+    DALI_LOG_RELEASE_INFO("window(%p) has been resized by server[%d, %d]\n", mEcoreWindow, newPositionSize.width, newPositionSize.height);
+    mResizeCompletedSignal.Emit(newSize);
+  }
+}
+
 void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
 {
   if(strcmp(interface, tizen_policy_interface.name) == 0)
index 0d23f71..af8054f 100644 (file)
@@ -178,6 +178,24 @@ public:
   void OnEcoreEventWindowAuxiliaryMessage(void* event);
 
   /**
+   * @brief Called when window has been moved by then display server.
+   * To move the window by display server, RequestMoveToServer() should be called.
+   * After the moving job is completed, this function will be called.
+   *
+   * @param[in] the completed event's data. It has the latest window geometry data.
+   */
+  void OnMoveCompleted(void* event);
+
+  /**
+   * @brief Called when window has been resized by then display server.
+   * To resize the window by display server, RequestResizeToServer() should be called.
+   * After the resizing job is completed, this function will be called.
+   *
+   * @param[in] the completed event's data. It has the latest window geometry data.
+   */
+  void OnResizeCompleted(void* event);
+
+  /**
    * @brief Called when a keymap is changed.
    */
   void KeymapChanged(void* data, int type, void* event);