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 cd0c8e5..6024db5 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 fdde5a7..765e66c 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 ace275e..2f4e99a 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 a6829f1..9423768 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 b74d7a5..a2ff543 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 d9aca61..782bc9e 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 ed618c2..99fab49 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 c9f558e..6bee6d3 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.
@@ -874,6 +884,14 @@ public: // Signals
   }
 
   /**
+   * @copydoc Dali::DevelWindow::PointerConstraintsSignal()
+   */
+  PointerConstraintsSignalType& PointerConstraintsSignal()
+  {
+    return mPointerConstraintsSignal;
+  }
+
+  /**
    * @copydoc Dali::DevelWindow::MoveCompletedSignal()
    */
   MoveCompletedSignalType& MoveCompletedSignal()
@@ -932,6 +950,7 @@ private:
   MoveCompletedSignalType                 mMoveCompletedSignal;
   ResizeCompletedSignalType               mResizeCompletedSignal;
   InsetsChangedSignalType                 mInsetsChangedSignal;
+  PointerConstraintsSignalType            mPointerConstraintsSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index 82d8a67..f28dc34 100644 (file)
@@ -485,6 +485,19 @@ static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
 }
 
 /**
+ * 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.
  */
 static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
@@ -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 271c518..0546e89 100644 (file)
@@ -116,6 +116,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.
    */
   void OnMouseWheel(void* data, int type, void* event);