[Tizen] Add window move/resize completed signal 70/292970/1
authorWonsik Jung <sidein@samsung.com>
Mon, 15 May 2023 10:44:55 +0000 (19:44 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 18 May 2023 01:04:19 +0000 (10:04 +0900)
When RequestMoveToServer() or RequestResizeToServer() is called, window start to be moved or resized by display server.
After the action is finished, server send the completed event.
This patch is to received the events.

Change-Id: I282e49cec906cff040bb34889b5c9f7a7250784b

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 b0d2bcffb1fbbd3496c22ba4751b21d88d3e1331..f224d972166edc7d37f9016501723da612e3f7b3 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 7021d3a62afd6db22119deca777e1de4fad5845c..897ea9f29bbb9156b020f23bc1da463dab2a3f40 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 94a3b30b1ac195fe97530f9175711d1cd9bea094..9cfaa8f4d703966310aedc3c4c40006377d0156f 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 114101b8d9dd9f065d8d19eb7f456b89aa07ef88..ddedc2ce8cb686473662a9c3047063a971f6dbfb 100644 (file)
@@ -41,7 +41,9 @@ WindowBase::WindowBase()
   mKeyboardRepeatSettingsChangedSignal(),
   mUpdatePositionSizeSignal(),
   mAuxiliaryMessageSignal(),
-  mMouseInOutEventSignal()
+  mMouseInOutEventSignal(),
+  mMoveCompletedSignal(),
+  mResizeCompletedSignal()
 {
 }
 
@@ -139,6 +141,16 @@ WindowBase::MouseInOutEventSignalType& WindowBase::MouseInOutEventSignal()
   return mMouseInOutEventSignal;
 }
 
+WindowBase::MoveCompletedSignalType& WindowBase::MoveCompletedSignal()
+{
+  return mMoveCompletedSignal;
+}
+
+WindowBase::ResizeCompletedSignalType& WindowBase::ResizeCompletedSignal()
+{
+  return mResizeCompletedSignal;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index b319c77e1dc0dbcc97cd0faa1abf4d16e55211cd..055edd01b9da9b5f0b65c7eaf97dd3ff038cdfa3 100644 (file)
@@ -76,6 +76,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;
@@ -540,7 +542,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();
 
@@ -554,6 +557,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;
@@ -580,6 +597,8 @@ protected:
   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
   MouseInOutEventSignalType               mMouseInOutEventSignal;
+  MoveCompletedSignalType                 mMoveCompletedSignal;
+  ResizeCompletedSignalType               mResizeCompletedSignal;
 };
 
 } // namespace Adaptor
index b1a43e030c92721a226ec3b74e2f298ed9c9c5a7..962584a869737c4413fd38352d137e699910a3a0 100644 (file)
@@ -95,6 +95,8 @@ Window::Window()
   mMovedSignal(),
   mOrientationChangedSignal(),
   mMouseInOutEventSignal(),
+  mMoveCompletedSignal(),
+  mResizeCompletedSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -160,6 +162,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);
@@ -1126,6 +1130,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 ac15bf845a3e2d258b07aed9f6af633f55bd4992..bdf5d62fcb84f03f2e945e0baa6c3e7472a9767e 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;
 
   /**
@@ -561,7 +563,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.
    */
@@ -603,6 +606,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.
    */
@@ -767,6 +784,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;
@@ -778,10 +811,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
@@ -798,6 +831,8 @@ private:
   MovedSignalType                         mMovedSignal;
   OrientationChangedSignalType            mOrientationChangedSignal;
   MouseInOutEventSignalType               mMouseInOutEventSignal;
+  MoveCompletedSignalType                 mMoveCompletedSignal;
+  ResizeCompletedSignalType               mResizeCompletedSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index 985f36ea554fe25200a3d6f19afacbc102e1e19c..dbf8c66a30a309d6b3dbbea73f832efaf8da8ba2 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);
@@ -966,6 +989,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);
 
@@ -1557,6 +1584,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 0d23f71bc05cbe49f570521fa3ca9a6e50dad5ed..af8054f79909f964a5f384a5bb9bfd854bb195fe 100644 (file)
@@ -177,6 +177,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.
    */