Add MouseInOutEventSignal 71/292271/4
authorjoogab.yun <joogab.yun@samsung.com>
Tue, 2 May 2023 10:20:20 +0000 (19:20 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 3 May 2023 04:04:01 +0000 (13:04 +0900)
MouseInOutEvent occurs when the mouse enters or leaves the window.

Change-Id: Iadf73d6755c9deabd1c26ddfeb6c410d5ec5c383

automated-tests/src/dali-adaptor/utc-Dali-Window.cpp
dali/devel-api/adaptor-framework/mouse-in-out-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 19100ce..b0d2bcf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * 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.
@@ -1592,3 +1592,18 @@ int UtcDaliWindowOrientationChangedSignalNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliWindowMouseInOutSignalNegative(void)
+{
+  Dali::Window instance;
+  try
+  {
+    DevelWindow::MouseInOutEventSignal(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/mouse-in-out-event.h b/dali/devel-api/adaptor-framework/mouse-in-out-event.h
new file mode 100644 (file)
index 0000000..7f8bcd1
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef DALI_WINDOW_DEVEL_MOUSE_IN_OUT_EVENT_H
+#define DALI_WINDOW_DEVEL_MOUSE_IN_OUT_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/device.h>
+#include <dali/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+namespace DevelWindow
+{
+/**
+ * @brief MouseInOutEvent occurs when the mouse enters or leaves the window.
+ *
+ * A signal is emitted whenever the mouse enters or leaves the window.
+ */
+struct DALI_ADAPTOR_API MouseInOutEvent
+{
+  enum class Type
+  {
+    NONE = 0,
+    IN,
+    OUT
+  };
+
+  /**
+   * @brief Constructor which creates a MouseInOutEvent instance
+   * @param[in] type The type of the event.
+   * @param[in] modifiers The modifier keys pressed during the event (such as shift, alt and control).
+   * @param[in] point The co-ordinates of the cursor relative to the top-left of the screen
+   * @param[in] timeStamp The time when the event being started.
+   * @param[in] deviceClass The device class the event originated from.
+   * @param[in] deviceSubclass The device subclass the event originated from.
+   */
+  MouseInOutEvent(Type type, uint32_t modifiers, Vector2 point, uint32_t timeStamp, const Device::Class::Type deviceClass, const Device::Subclass::Type deviceSubclass)
+  : type(type),
+    modifiers(modifiers),
+    point(point),
+    timeStamp(timeStamp),
+    deviceClass(deviceClass),
+    deviceSubclass(deviceSubclass)
+  {
+  }
+
+  Type                         type;
+  uint32_t                     modifiers;
+  Vector2                      point;
+  uint32_t                     timeStamp;
+  const Device::Class::Type    deviceClass;
+  const Device::Subclass::Type deviceSubclass;
+};
+
+} // namespace DevelWindow
+
+} // namespace Dali
+
+#endif // DALI_WINDOW_DEVEL_MOUSE_IN_OUT_EVENT_H
index 25f5bd1..7021d3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -279,6 +279,11 @@ InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window)
   return GetImplementation(window).InterceptKeyEventSignal();
 }
 
+MouseInOutEventSignalType& MouseInOutEventSignal(Window window)
+{
+  return GetImplementation(window).MouseInOutEventSignal();
+}
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 372c548..94a3b30 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_WINDOW_DEVEL_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -22,6 +22,7 @@
 #include <memory>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/mouse-in-out-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>
@@ -48,6 +49,7 @@ typedef Signal<void(Window, bool)>
 typedef Signal<bool(const KeyEvent&)>                                                InterceptKeyEventSignalType;             ///< Intercept Key event signal type
 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
 
 /**
  * @brief Creates an initialized handle to a new Window.
@@ -559,6 +561,19 @@ DALI_ADAPTOR_API MovedSignalType& MovedSignal(Window window);
  */
 DALI_ADAPTOR_API OrientationChangedSignalType& OrientationChangedSignal(Window window);
 
+/**
+ * @brief This signal is emitted when the mouse in or out event is received.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Window window, Dali::MouseInOutEvent event );
+ * @endcode
+ *
+ * @param[in] window The window instance.
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API MouseInOutEventSignalType& MouseInOutEventSignal(Window window);
+
 } // namespace DevelWindow
 
 } // namespace Dali
index 8cf5583..941a600 100755 (executable)
@@ -86,6 +86,7 @@ SET( devel_api_adaptor_framework_header_files
   ${adaptor_devel_api_dir}/adaptor-framework/input-method-options.h
   ${adaptor_devel_api_dir}/adaptor-framework/keyboard.h
   ${adaptor_devel_api_dir}/adaptor-framework/lifecycle-controller.h
+  ${adaptor_devel_api_dir}/adaptor-framework/mouse-in-out-event.h
   ${adaptor_devel_api_dir}/adaptor-framework/native-image-source-devel.h
   ${adaptor_devel_api_dir}/adaptor-framework/native-image-source-queue.h
   ${adaptor_devel_api_dir}/adaptor-framework/orientation.h
index 5682031..9882b0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * 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.
@@ -41,7 +41,8 @@ WindowBase::WindowBase()
   mTransitionEffectEventSignal(),
   mKeyboardRepeatSettingsChangedSignal(),
   mUpdatePositionSizeSignal(),
-  mAuxiliaryMessageSignal()
+  mAuxiliaryMessageSignal(),
+  mMouseInOutEventSignal()
 {
 }
 
@@ -139,6 +140,11 @@ WindowBase::AuxiliaryMessageSignalType& WindowBase::AuxiliaryMessageSignal()
   return mAuxiliaryMessageSignal;
 }
 
+WindowBase::MouseInOutEventSignalType& WindowBase::MouseInOutEventSignal()
+{
+  return mMouseInOutEventSignal;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 3a1784d..6cb6819 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -27,6 +27,7 @@
 #include <vector>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/mouse-in-out-event.h>
 #include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/internal/graphics/gles/egl-implementation.h>
 #include <dali/internal/window-system/common/damage-observer.h>
@@ -63,18 +64,19 @@ public:
   };
 
   // Window
-  typedef Signal<void(bool)>                                IconifySignalType;
-  typedef Signal<void(bool)>                                MaximizeSignalType;
-  typedef Signal<void(bool)>                                FocusSignalType;
-  typedef Signal<void()>                                    OutputSignalType;
-  typedef Signal<void()>                                    DeleteSignalType;
-  typedef Signal<void(const DamageArea&)>                   DamageSignalType;
-  typedef Signal<void(const RotationEvent&)>                RotationSignalType;
-  typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
-  typedef Signal<void()>                                    KeyboardRepeatSettingsChangedSignalType;
-  typedef Signal<void()>                                    WindowRedrawRequestSignalType;
-  typedef Signal<void(Dali::PositionSize&)>                 UpdatePositionSizeType;
-  typedef Signal<void(const std::string&, const std::string&, const Property::Array&)>             AuxiliaryMessageSignalType;
+  typedef Signal<void(bool)>                                                           IconifySignalType;
+  typedef Signal<void(bool)>                                                           MaximizeSignalType;
+  typedef Signal<void(bool)>                                                           FocusSignalType;
+  typedef Signal<void()>                                                               OutputSignalType;
+  typedef Signal<void()>                                                               DeleteSignalType;
+  typedef Signal<void(const DamageArea&)>                                              DamageSignalType;
+  typedef Signal<void(const RotationEvent&)>                                           RotationSignalType;
+  typedef Signal<void(WindowEffectState, WindowEffectType)>                            TransitionEffectEventSignalType;
+  typedef Signal<void()>                                                               KeyboardRepeatSettingsChangedSignalType;
+  typedef Signal<void()>                                                               WindowRedrawRequestSignalType;
+  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;
 
   // Input events
   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
@@ -85,7 +87,7 @@ public:
   typedef Signal<void(void*)> SelectionSignalType;
 
   // Accessibility
-  typedef Signal<void(StyleChange::Type)>        StyleSignalType;
+  typedef Signal<void(StyleChange::Type)> StyleSignalType;
 
   /**
    * @brief Default constructor
@@ -553,6 +555,11 @@ public:
    */
   AuxiliaryMessageSignalType& AuxiliaryMessageSignal();
 
+  /**
+   * @brief This signal is emitted when a mouse in or out event is recevied.
+   */
+  MouseInOutEventSignalType& MouseInOutEventSignal();
+
 protected:
   // Undefined
   WindowBase(const WindowBase&) = delete;
@@ -579,6 +586,7 @@ protected:
   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
+  MouseInOutEventSignalType               mMouseInOutEventSignal;
 };
 
 } // namespace Adaptor
index e7fdf0d..1afa98e 100644 (file)
@@ -93,6 +93,7 @@ Window::Window()
   mAuxiliaryMessageSignal(),
   mMovedSignal(),
   mOrientationChangedSignal(),
+  mMouseInOutEventSignal(),
   mLastKeyEvent(),
   mLastTouchEvent(),
   mIsTransparent(false),
@@ -159,6 +160,7 @@ void Window::Initialize(Any surface, const PositionSize& positionSize, const std
   mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
   mWindowBase->UpdatePositionSizeSignal().Connect(this, &Window::OnUpdatePositionSize);
   mWindowBase->AuxiliaryMessageSignal().Connect(this, &Window::OnAuxiliaryMessage);
+  mWindowBase->MouseInOutEventSignal().Connect(this, &Window::OnMouseInOutEvent);
 
   mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
   mWindowSurface->RotationFinishedSignal().Connect(this, &Window::OnRotationFinished);
@@ -1043,6 +1045,13 @@ void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
   FeedKeyEvent(keyEvent);
 }
 
+void Window::OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent)
+{
+  Dali::Window handle(this);
+
+  mMouseInOutEventSignal.Emit(handle, mouseInOutEvent);
+}
+
 void Window::OnRotation(const RotationEvent& rotation)
 {
   PositionSize newPositionSize(rotation.x, rotation.y, rotation.width, rotation.height);
index bb49a8d..35d96c5 100644 (file)
@@ -50,9 +50,10 @@ class WindowRenderSurface;
 class WindowBase;
 
 class Window;
-using WindowPtr       = IntrusivePtr<Window>;
-using OrientationPtr  = IntrusivePtr<Orientation>;
-using EventHandlerPtr = IntrusivePtr<EventHandler>;
+using WindowPtr          = IntrusivePtr<Window>;
+using OrientationPtr     = IntrusivePtr<Orientation>;
+using MouseInOutEventPtr = IntrusivePtr<Dali::DevelWindow::MouseInOutEvent>;
+using EventHandlerPtr    = IntrusivePtr<EventHandler>;
 
 /**
  * Window provides a surface to render onto with orientation & indicator properties.
@@ -69,6 +70,7 @@ public:
   typedef Dali::DevelWindow::AccessibilityHighlightSignalType        AccessibilityHighlightSignalType;
   typedef Dali::DevelWindow::MovedSignalType                         MovedSignalType;
   typedef Dali::DevelWindow::OrientationChangedSignalType            OrientationChangedSignalType;
+  typedef Dali::DevelWindow::MouseInOutEventSignalType               MouseInOutEventSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
@@ -426,7 +428,7 @@ public:
    *
    * @param[in] renderNotification to use
    */
-  void SetRenderNotification(TriggerEventInterface *renderNotification);
+  void SetRenderNotification(TriggerEventInterfacerenderNotification);
 
 public: // Dali::Internal::Adaptor::SceneHolder
   /**
@@ -601,6 +603,12 @@ private:
   void OnRotationFinished();
 
   /**
+   * @brief Called when the mouse in or out event is received.
+   * @param[in] mouseInOutEvent the mouse event
+   */
+  void OnMouseInOutEvent(const Dali::DevelWindow::MouseInOutEvent& mouseInOutEvent);
+
+  /**
    * @brief Set available orientation to window base.
    */
   void SetAvailableAnlges(const std::vector<int>& angles);
@@ -756,6 +764,14 @@ public: // Signals
     return mOrientationChangedSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::MouseInOutEventSignal()
+   */
+  MouseInOutEventSignalType& MouseInOutEventSignal()
+  {
+    return mMouseInOutEventSignal;
+  }
+
 private:
   WindowRenderSurface* mWindowSurface; ///< The window rendering surface
   WindowBase*          mWindowBase;
@@ -786,6 +802,7 @@ private:
   AccessibilityHighlightSignalType        mAccessibilityHighlightSignal;
   MovedSignalType                         mMovedSignal;
   OrientationChangedSignalType            mOrientationChangedSignal;
+  MouseInOutEventSignalType               mMouseInOutEventSignal;
 
   Dali::KeyEvent   mLastKeyEvent;
   Dali::TouchEvent mLastTouchEvent;
index 468fc54..6d92dae 100644 (file)
@@ -471,6 +471,32 @@ static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
 }
 
 /**
+ * Called when a mouse in is received.
+ */
+static Eina_Bool EcoreEventMouseIn(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::IN);
+  }
+  return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
+ * Called when a mouse out is received.
+ */
+static Eina_Bool EcoreEventMouseOut(void* data, int type, void* event)
+{
+  WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+  if(windowBase)
+  {
+    windowBase->OnMouseInOut(data, type, event, Dali::DevelWindow::MouseInOutEvent::Type::OUT);
+  }
+  return ECORE_CALLBACK_PASS_ON;
+}
+
+/**
  * Called when a detent rotation event is recevied.
  */
 static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
@@ -886,6 +912,10 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   // Register Mouse wheel events
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
 
+  // Register Mouse IO events
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, EcoreEventMouseIn, this));
+  mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseOut, this));
+
   // Register Detent event
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
 
@@ -1265,6 +1295,28 @@ void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
   }
 }
 
+void WindowBaseEcoreWl2::OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action)
+{
+  Ecore_Event_Mouse_IO* mouseInOutEvent = static_cast<Ecore_Event_Mouse_IO*>(event);
+
+  if(mouseInOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
+  {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_ON_MOUSE_IN_OUT");
+
+    DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseInOut: timestamp: %d, modifiers: %d, x: %d, y: %d\n", mouseInOutEvent->timestamp, mouseInOutEvent->modifiers, mouseInOutEvent->x, mouseInOutEvent->y);
+
+    Device::Class::Type    deviceClass;
+    Device::Subclass::Type deviceSubclass;
+
+    GetDeviceClass(ecore_device_class_get(mouseInOutEvent->dev), deviceClass);
+    GetDeviceSubclass(ecore_device_subclass_get(mouseInOutEvent->dev), deviceSubclass);
+
+    Dali::DevelWindow::MouseInOutEvent inOutEvent(action, mouseInOutEvent->modifiers, Vector2(mouseInOutEvent->x, mouseInOutEvent->y), mouseInOutEvent->timestamp, deviceClass, deviceSubclass);
+
+    mMouseInOutEventSignal.Emit(inOutEvent);
+  }
+}
+
 void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
 {
   Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
index ee2ed72..0d23f71 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * 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.
@@ -116,6 +116,11 @@ public:
   void OnMouseWheel(void* data, int type, void* event);
 
   /**
+   * @brief Called when a mouse in or out is received.
+   */
+  void OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action);
+
+  /**
    * @brief Called when a detent rotation event is recevied.
    */
   void OnDetentRotation(void* data, int type, void* event);
@@ -273,7 +278,7 @@ public:
    */
   void MoveResize(PositionSize positionSize) override;
 
- /**
 /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
    */
   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
@@ -577,7 +582,6 @@ private:
    */
   PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
 
-
   /**
    * @brief Return the rect value to recalulate with the default system coordinates.
    *