From: joogab.yun Date: Tue, 2 May 2023 10:20:20 +0000 (+0900) Subject: Add MouseInOutEventSignal X-Git-Tag: dali_2.2.25~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=c695717b383a197bb171314d7bfbfe008be42ec5 Add MouseInOutEventSignal MouseInOutEvent occurs when the mouse enters or leaves the window. Change-Id: Iadf73d6755c9deabd1c26ddfeb6c410d5ec5c383 --- diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index 19100ce..b0d2bcf 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -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 index 0000000..7f8bcd1 --- /dev/null +++ b/dali/devel-api/adaptor-framework/mouse-in-out-event.h @@ -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 +#include + +// INTERNAL INCLUDES +#include + +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 diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp index 25f5bd1..7021d3a 100644 --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -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 diff --git a/dali/devel-api/adaptor-framework/window-devel.h b/dali/devel-api/adaptor-framework/window-devel.h index 372c548..94a3b30 100644 --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -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 // INTERNAL INCLUDES +#include #include #include #include @@ -48,6 +49,7 @@ typedef Signal typedef Signal InterceptKeyEventSignalType; ///< Intercept Key event signal type typedef Signal MovedSignalType; ///< Window Moved signal type typedef Signal OrientationChangedSignalType; ///< Window orientation changed signal type +typedef Signal 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 diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 8cf5583..941a600 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 diff --git a/dali/internal/window-system/common/window-base.cpp b/dali/internal/window-system/common/window-base.cpp index 5682031..9882b0d 100644 --- a/dali/internal/window-system/common/window-base.cpp +++ b/dali/internal/window-system/common/window-base.cpp @@ -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 diff --git a/dali/internal/window-system/common/window-base.h b/dali/internal/window-system/common/window-base.h index 3a1784d..6cb6819 100644 --- a/dali/internal/window-system/common/window-base.h +++ b/dali/internal/window-system/common/window-base.h @@ -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 // INTERNAL INCLUDES +#include #include #include #include @@ -63,18 +64,19 @@ public: }; // Window - typedef Signal IconifySignalType; - typedef Signal MaximizeSignalType; - typedef Signal FocusSignalType; - typedef Signal OutputSignalType; - typedef Signal DeleteSignalType; - typedef Signal DamageSignalType; - typedef Signal RotationSignalType; - typedef Signal TransitionEffectEventSignalType; - typedef Signal KeyboardRepeatSettingsChangedSignalType; - typedef Signal WindowRedrawRequestSignalType; - typedef Signal UpdatePositionSizeType; - typedef Signal AuxiliaryMessageSignalType; + typedef Signal IconifySignalType; + typedef Signal MaximizeSignalType; + typedef Signal FocusSignalType; + typedef Signal OutputSignalType; + typedef Signal DeleteSignalType; + typedef Signal DamageSignalType; + typedef Signal RotationSignalType; + typedef Signal TransitionEffectEventSignalType; + typedef Signal KeyboardRepeatSettingsChangedSignalType; + typedef Signal WindowRedrawRequestSignalType; + typedef Signal UpdatePositionSizeType; + typedef Signal AuxiliaryMessageSignalType; + typedef Signal MouseInOutEventSignalType; // Input events typedef Signal TouchEventSignalType; @@ -85,7 +87,7 @@ public: typedef Signal SelectionSignalType; // Accessibility - typedef Signal StyleSignalType; + typedef Signal 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 diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index e7fdf0d..1afa98e 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -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); diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index bb49a8d..35d96c5 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -50,9 +50,10 @@ class WindowRenderSurface; class WindowBase; class Window; -using WindowPtr = IntrusivePtr; -using OrientationPtr = IntrusivePtr; -using EventHandlerPtr = IntrusivePtr; +using WindowPtr = IntrusivePtr; +using OrientationPtr = IntrusivePtr; +using MouseInOutEventPtr = IntrusivePtr; +using EventHandlerPtr = IntrusivePtr; /** * 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 SignalType; /** @@ -426,7 +428,7 @@ public: * * @param[in] renderNotification to use */ - void SetRenderNotification(TriggerEventInterface *renderNotification); + void SetRenderNotification(TriggerEventInterface* renderNotification); 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& 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; diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp index 468fc54..6d92dae 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -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(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(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(event); + + if(mouseInOutEvent->window == static_cast(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(event); diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h index ee2ed72..0d23f71 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -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. *