From: joogab.yun Date: Wed, 6 Sep 2023 10:31:12 +0000 (+0900) Subject: Add ECORE_WL2_EVENT_POINTER_CONSTRAINTS event X-Git-Tag: dali_2.2.44~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F298394%2F5;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Add ECORE_WL2_EVENT_POINTER_CONSTRAINTS event Change-Id: I1f3197dcab060053bc3a86be8be0b8730c178d5e --- diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp index cd0c8e5..6024db5 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-Window.cpp @@ -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 index 0000000..184f07d --- /dev/null +++ b/dali/devel-api/adaptor-framework/pointer-constraints-event.h @@ -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 + +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 diff --git a/dali/devel-api/adaptor-framework/window-devel.cpp b/dali/devel-api/adaptor-framework/window-devel.cpp index fdde5a7..765e66c 100644 --- a/dali/devel-api/adaptor-framework/window-devel.cpp +++ b/dali/devel-api/adaptor-framework/window-devel.cpp @@ -359,6 +359,11 @@ MouseRelativeEventSignalType& MouseRelativeEventSignal(Window window) return GetImplementation(window).MouseRelativeEventSignal(); } +PointerConstraintsSignalType& PointerConstraintsSignal(Window window) +{ + return GetImplementation(window).PointerConstraintsSignal(); +} + } // 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 ace275e..2f4e99a 100644 --- a/dali/devel-api/adaptor-framework/window-devel.h +++ b/dali/devel-api/adaptor-framework/window-devel.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -55,6 +56,7 @@ typedef Signal typedef Signal MoveCompletedSignalType; ///< Window Moved by Server signal type typedef Signal ResizeCompletedSignalType; ///< Window Resized by Server signal type typedef Signal InsetsChangedSignalType; ///< InsetsChanged signal type +typedef Signal 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 diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index a6829f1..9423768 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 diff --git a/dali/internal/window-system/common/window-base.cpp b/dali/internal/window-system/common/window-base.cpp index b74d7a5..a2ff543 100644 --- a/dali/internal/window-system/common/window-base.cpp +++ b/dali/internal/window-system/common/window-base.cpp @@ -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 diff --git a/dali/internal/window-system/common/window-base.h b/dali/internal/window-system/common/window-base.h index d9aca61..782bc9e 100644 --- a/dali/internal/window-system/common/window-base.h +++ b/dali/internal/window-system/common/window-base.h @@ -81,6 +81,7 @@ public: typedef Signal MoveCompletedSignalType; typedef Signal ResizeCompletedSignalType; typedef Signal InsetsChangedSignalType; + typedef Signal PointerConstraintsSignalType; // Input events typedef Signal 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 diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index ed618c2..99fab49 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -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(newPosition.x), static_cast(newPosition.y), locked, confined); + + mPointerConstraintsSignal.Emit(handle, pointerConstraintsEvent); } void Window::OnRotation(const RotationEvent& rotation) diff --git a/dali/internal/window-system/common/window-impl.h b/dali/internal/window-system/common/window-impl.h index c9f558e..6bee6d3 100644 --- a/dali/internal/window-system/common/window-impl.h +++ b/dali/internal/window-system/common/window-impl.h @@ -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 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; 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 82d8a67..f28dc34 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 @@ -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(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(event); + + if(constraintsEvent && constraintsEvent->win == static_cast(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(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 271c518..0546e89 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 @@ -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);