Add ECORE_WL2_EVENT_POINTER_CONSTRAINTS event 94/298394/5
authorjoogab.yun <joogab.yun@samsung.com>
Wed, 6 Sep 2023 10:31:12 +0000 (19:31 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Fri, 8 Sep 2023 08:46:09 +0000 (17:46 +0900)
Change-Id: I1f3197dcab060053bc3a86be8be0b8730c178d5e

automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/pointer-constraints-event.h [new file with mode: 0644]
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/devel-api/file.list
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 cd0c8e536d71bc0eaf170677637acf5792992201..6024db5f6b13a1755c278754eb1f1bbe8dfe4fee 100644 (file)
@@ -1652,3 +1652,18 @@ int UtcDaliWindowResizeCompletedSignalNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliWindowPointerConstraintsSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::PointerConstraintsSignal(instance);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
diff --git a/dali/devel-api/adaptor-framework/pointer-constraints-event.h b/dali/devel-api/adaptor-framework/pointer-constraints-event.h
new file mode 100644 (file)
index 0000000..184f07d
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef DALI_WINDOW_DEVEL_POINTER_CONSTRAINTS_EVENT_H
+#define DALI_WINDOW_DEVEL_POINTER_CONSTRAINTS_EVENT_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+namespace DevelWindow
+{
+/**
+ * @brief PointerConstraintsEvent occurs when pointer is locked/unlocked.
+ *
+ * A signal is emitted when pointer is locked/unlocked.
+ */
+struct DALI_ADAPTOR_API PointerConstraintsEvent
+{
+  /**
+   * @brief Constructor which creates a PointerConstraintsEvent instance
+   * @param[in] x The x coordinate relative to window where event happened
+   * @param[in] y The y coordinate relative to window where event happened
+   * @param[in] locked The status whether pointer is locked/unlocked
+   * @param[in] confined The status whether pointer is confined/unconfined
+   */
+  PointerConstraintsEvent(int32_t x, int32_t y, bool locked, bool confined)
+  : x(x),
+    y(y),
+    locked(locked),
+    confined(confined)
+  {
+  }
+
+  int32_t x;
+  int32_t y;
+  bool    locked;
+  bool    confined;
+};
+
+} // namespace DevelWindow
+
+} // namespace Dali
+
+#endif // DALI_WINDOW_DEVEL_POINTER_CONSTRAINTS_EVENT_H
index fdde5a782820abc1067077851c422be78057f7e3..765e66c64ac7fa523ed54b092fa7a848c96d2702 100644 (file)
@@ -359,6 +359,11 @@ MouseRelativeEventSignalType& MouseRelativeEventSignal(Window window)
   return GetImplementation(window).MouseRelativeEventSignal();
 }
 
+PointerConstraintsSignalType& PointerConstraintsSignal(Window window)
+{
+  return GetImplementation(window).PointerConstraintsSignal();
+}
+
 } // namespace DevelWindow
 
 } // namespace Dali
index ace275e05617cacff754ba815c035e40518e59d6..2f4e99ab5200faa0856018a20846b947ba0a46cf 100644 (file)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
 #include <dali/devel-api/adaptor-framework/mouse-relative-event.h>
+#include <dali/devel-api/adaptor-framework/pointer-constraints-event.h>
 #include <dali/public-api/adaptor-framework/window-enumerations.h>
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/common/vector-wrapper.h>
@@ -55,6 +56,7 @@ typedef Signal<void(Window, const Dali::DevelWindow::MouseRelativeEvent&)>
 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
 typedef Signal<void(WindowInsetsPartType, WindowInsetsPartState, const Extents&)>    InsetsChangedSignalType;                 ///< InsetsChanged signal type
+typedef Signal<void(Window, const Dali::DevelWindow::PointerConstraintsEvent&)>      PointerConstraintsSignalType;            ///< PointerConstraintsEvent signal type
 
 /**
  * @brief Creates an initialized handle to a new Window.
@@ -720,6 +722,14 @@ DALI_ADAPTOR_API ResizeCompletedSignalType& ResizeCompletedSignal(Window window)
  */
 DALI_ADAPTOR_API InsetsChangedSignalType& InsetsChangedSignal(Window window);
 
+/**
+ * @brief This signal is emitted when pointer is locked/unlocked
+ *
+ * @param[in] window The window instance
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API PointerConstraintsSignalType& PointerConstraintsSignal(Window window);
+
 } // namespace DevelWindow
 
 } // namespace Dali
index a6829f10dd4d616703e922c0292ceac31f2adbfe..94237689eee5eaa01dbbd4c6d33b40805b9062d1 100755 (executable)
@@ -92,6 +92,7 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/orientation.h
   ${adaptor_devel_api_dir}/adaptor-framework/performance-logger.h
   ${adaptor_devel_api_dir}/adaptor-framework/pixel-buffer.h
+  ${adaptor_devel_api_dir}/adaptor-framework/pointer-constraints-event.h
   ${adaptor_devel_api_dir}/adaptor-framework/proxy-accessible.h
   ${adaptor_devel_api_dir}/adaptor-framework/sound-player.h
   ${adaptor_devel_api_dir}/adaptor-framework/style-monitor.h
index b74d7a58521e2a4a923959b45edbf74297b68456..a2ff543b439ec458f2c9c2b3d7d22eaa0a51fd5a 100644 (file)
@@ -46,7 +46,8 @@ WindowBase::WindowBase()
   mMouseRelativeEventSignal(),
   mMoveCompletedSignal(),
   mResizeCompletedSignal(),
-  mInsetsChangedSignal()
+  mInsetsChangedSignal(),
+  mPointerConstraintsSignal()
 {
 }
 
@@ -169,6 +170,11 @@ WindowBase::InsetsChangedSignalType& WindowBase::InsetsChangedSignal()
   return mInsetsChangedSignal;
 }
 
+WindowBase::PointerConstraintsSignalType& WindowBase::PointerConstraintsSignal()
+{
+  return mPointerConstraintsSignal;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index d9aca61c63d5f251fe45e048142bd8501a47494e..782bc9e7d782511d2562eefa36cf1058f07baf87 100644 (file)
@@ -81,6 +81,7 @@ public:
   typedef Signal<void(Dali::Int32Pair&)>                                               MoveCompletedSignalType;
   typedef Signal<void(Dali::Uint16Pair&)>                                              ResizeCompletedSignalType;
   typedef Signal<void(WindowInsetsPartType, WindowInsetsPartState, const Extents&)>    InsetsChangedSignalType;
+  typedef Signal<void(const Dali::Int32Pair&, bool, bool)>                             PointerConstraintsSignalType;
 
   // Input events
   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
@@ -651,6 +652,11 @@ public:
    */
   InsetsChangedSignalType& InsetsChangedSignal();
 
+  /**
+   * @brief This signal is emitted when window pointer is locked/unlocked
+   */
+  PointerConstraintsSignalType& PointerConstraintsSignal();
+
 protected:
   // Undefined
   WindowBase(const WindowBase&) = delete;
@@ -682,6 +688,7 @@ protected:
   MoveCompletedSignalType                 mMoveCompletedSignal;
   ResizeCompletedSignalType               mResizeCompletedSignal;
   InsetsChangedSignalType                 mInsetsChangedSignal;
+  PointerConstraintsSignalType            mPointerConstraintsSignal;
 };
 
 } // namespace Adaptor
index ed618c2aadb4f8919612b60796f900f0470b375b..99fab49bb7de6d1a6285c16b3aa11dc6db7020de 100644 (file)
@@ -96,6 +96,7 @@ Window::Window()
   mMoveCompletedSignal(),
   mResizeCompletedSignal(),
   mInsetsChangedSignal(),
+  mPointerConstraintsSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -167,6 +168,7 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->MouseRelativeEventSignal().Connect(this, &Window::OnMouseRelativeEvent);
   mWindowBase->MoveCompletedSignal().Connect(this, &Window::OnMoveCompleted);
   mWindowBase->ResizeCompletedSignal().Connect(this, &Window::OnResizeCompleted);
+  mWindowBase->PointerConstraintsSignal().Connect(this, &Window::OnPointerConstraints);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
@@ -1081,11 +1083,21 @@ void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseIn
   mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
 }
 
-void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& MouseRelativeEvent)
+void Window::OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent)
 {
   Dali::Window handle(this);
 
-  mMouseRelativeEventSignal.Emit(handle, MouseRelativeEvent);
+  mMouseRelativeEventSignal.Emit(handle, mouseRelativeEvent);
+}
+
+void Window::OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined)
+{
+  Dali::Window handle(this);
+
+  Vector2                                    newPosition = RecalculatePosition(Vector2(position.GetX(), position.GetY()));
+  Dali::DevelWindow::PointerConstraintsEvent pointerConstraintsEvent(static_cast<int32_t>(newPosition.x), static_cast<int32_t>(newPosition.y), locked, confined);
+
+  mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent);
 }
 
 void Window::OnRotation(const RotationEvent& rotation)
index c9f558eec9ff9b65b4502ab6e77783f1f7ba30c6..6bee6d3b9d675ac8a6392c68b8561fa248d5f9ef 100644 (file)
@@ -75,6 +75,7 @@ public:
   typedef Dali::DevelWindow::MoveCompletedSignalType                 MoveCompletedSignalType;
   typedef Dali::DevelWindow::ResizeCompletedSignalType               ResizeCompletedSignalType;
   typedef Dali::DevelWindow::InsetsChangedSignalType                 InsetsChangedSignalType;
+  typedef Dali::DevelWindow::PointerConstraintsSignalType            PointerConstraintsSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
@@ -666,9 +667,18 @@ private:
 
   /**
    * @brief Called when the mouse relative event is received.
-   * @param[in] MouseRelativeEvent the mouse event
+   * @param[in] mouseRelativeEvent the mouse event
    */
-  void OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& MouseRelativeEvent);
+  void OnMouseRelativeEvent(const Dali::DevelWindow::MouseRelativeEvent& mouseRelativeEvent);
+
+  /**
+   * @brief Called when the pointer is locked/unlocked
+   *
+   * @param[in] position The x, y coordinate relative to window where event happened
+   * @param[in] locked The status whether pointer is locked/unlocked
+   * @param[in] confined The status whether pointer is confined/unconfined
+   */
+  void OnPointerConstraints(const Dali::Int32Pair& position, bool locked, bool confined);
 
   /**
    * @brief Called when the window is moved by display server.
@@ -873,6 +883,14 @@ public: // Signals
     return mMouseRelativeEventSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::PointerConstraintsSignal()
+   */
+  PointerConstraintsSignalType& PointerConstraintsSignal()
+  {
+    return mPointerConstraintsSignal;
+  }
+
   /**
    * @copydoc Dali::DevelWindow::MoveCompletedSignal()
    */
@@ -932,6 +950,7 @@ private:
   MoveCompletedSignalType                 mMoveCompletedSignal;
   ResizeCompletedSignalType               mResizeCompletedSignal;
   InsetsChangedSignalType                 mInsetsChangedSignal;
+  PointerConstraintsSignalType            mPointerConstraintsSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index 82d8a67ed55b05c912cadb8162ef8eab1feaac18..f28dc34dd3405f2800708c502df656b8f995b027 100644 (file)
@@ -484,6 +484,19 @@ static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
   return ECORE_CALLBACK_PASS_ON;
 }
 
+/**
+ * Called when pointer constraints event is recevied.
+ */
+static Eina_Bool EcoreEventPointerConstraints(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnPointerConstraints(data, type, event);
+  }
+  return ECORE_CALLBACK_PASS_ON;
+}
+
 /**
  * Called when a mouse wheel is received.
  */
@@ -990,6 +1003,9 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_RELATIVE_MOVE, EcoreEventMouseButtonRelativeMove, this));
 
+  // Register pointer lock/unlock event
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_POINTER_CONSTRAINTS, EcoreEventPointerConstraints, this));
+
   // Register Mouse wheel events
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
 
@@ -1354,9 +1370,9 @@ void WindowBaseEcoreWl2::OnMouseButtonRelativeMove(void* data, int type, void* e
     GetDeviceClass(ecore_device_class_get(relativeMoveEvent->dev), deviceClass);
     GetDeviceSubclass(ecore_device_subclass_get(relativeMoveEvent->dev), deviceSubclass);
 
-    Dali::DevelWindow::MouseRelativeEvent MouseRelativeEvent(Dali::DevelWindow::MouseRelativeEvent::Type::RELATIVE_MOVE, relativeMoveEvent->modifiers, relativeMoveEvent->timestamp, Vector2(relativeMoveEvent->dx, relativeMoveEvent->dy), Vector2(relativeMoveEvent->dx_unaccel, relativeMoveEvent->dy_unaccel), deviceClass, deviceSubclass);
+    Dali::DevelWindow::MouseRelativeEvent mouseRelativeEvent(Dali::DevelWindow::MouseRelativeEvent::Type::RELATIVE_MOVE, relativeMoveEvent->modifiers, relativeMoveEvent->timestamp, Vector2(relativeMoveEvent->dx, relativeMoveEvent->dy), Vector2(relativeMoveEvent->dx_unaccel, relativeMoveEvent->dy_unaccel), deviceClass, deviceSubclass);
 
-    mMouseRelativeEventSignal.Emit(MouseRelativeEvent);
+    mMouseRelativeEventSignal.Emit(mouseRelativeEvent);
   }
 }
 
@@ -1379,6 +1395,20 @@ void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
   }
 }
 
+void WindowBaseEcoreWl2::OnPointerConstraints(void* data, int type, void* event)
+{
+  Ecore_Wl2_Event_Pointer_Constraints* constraintsEvent = static_cast<Ecore_Wl2_Event_Pointer_Constraints*>(event);
+
+  if(constraintsEvent && constraintsEvent->win == static_cast<uint32_t>(ecore_wl2_window_id_get(mEcoreWindow)))
+  {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_POINTER_CONSTRAINTS");
+    Dali::Int32Pair position(constraintsEvent->x, constraintsEvent->y);
+    DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::OnPointerConstraints[%d, %d]\n", position.GetX(), position.GetY());
+
+    mPointerConstraintsSignal.Emit(position, constraintsEvent->locked, constraintsEvent->confined);
+  }
+}
+
 void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
 {
   Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
index 271c5188ff164c0f346a11f4a7f0a59be8605a60..0546e89d4469d5c2071ea6ad6f12f438b02b8369 100644 (file)
@@ -115,6 +115,11 @@ public:
    */
   void OnMouseButtonCancel(void* data, int type, void* event);
 
+  /**
+   * @brief Called when a pointer is locked or unlocked.
+   */
+  void OnPointerConstraints(void* data, int type, void* event);
+
   /**
    * @brief Called when a mouse wheel is received.
    */