}
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;
+}
--- /dev/null
+#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
return GetImplementation(window).MouseRelativeEventSignal();
}
+PointerConstraintsSignalType& PointerConstraintsSignal(Window window)
+{
+ return GetImplementation(window).PointerConstraintsSignal();
+}
+
} // namespace DevelWindow
} // namespace Dali
// 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>
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.
*/
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
${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
mMouseRelativeEventSignal(),
mMoveCompletedSignal(),
mResizeCompletedSignal(),
- mInsetsChangedSignal()
+ mInsetsChangedSignal(),
+ mPointerConstraintsSignal()
{
}
return mInsetsChangedSignal;
}
+WindowBase::PointerConstraintsSignalType& WindowBase::PointerConstraintsSignal()
+{
+ return mPointerConstraintsSignal;
+}
+
} // namespace Adaptor
} // namespace Internal
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;
*/
InsetsChangedSignalType& InsetsChangedSignal();
+ /**
+ * @brief This signal is emitted when window pointer is locked/unlocked
+ */
+ PointerConstraintsSignalType& PointerConstraintsSignal();
+
protected:
// Undefined
WindowBase(const WindowBase&) = delete;
MoveCompletedSignalType mMoveCompletedSignal;
ResizeCompletedSignalType mResizeCompletedSignal;
InsetsChangedSignalType mInsetsChangedSignal;
+ PointerConstraintsSignalType mPointerConstraintsSignal;
};
} // namespace Adaptor
mMoveCompletedSignal(),
mResizeCompletedSignal(),
mInsetsChangedSignal(),
+ mPointerConstraintsSignal(),
mLastKeyEvent(),
mLastTouchEvent(),
mIsTransparent(false),
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);
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)
typedef Dali::DevelWindow::MoveCompletedSignalType MoveCompletedSignalType;
typedef Dali::DevelWindow::ResizeCompletedSignalType ResizeCompletedSignalType;
typedef Dali::DevelWindow::InsetsChangedSignalType InsetsChangedSignalType;
+ typedef Dali::DevelWindow::PointerConstraintsSignalType PointerConstraintsSignalType;
typedef Signal<void()> SignalType;
/**
/**
* @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.
return mMouseRelativeEventSignal;
}
+ /**
+ * @copydoc Dali::DevelWindow::PointerConstraintsSignal()
+ */
+ PointerConstraintsSignalType& PointerConstraintsSignal()
+ {
+ return mPointerConstraintsSignal;
+ }
+
/**
* @copydoc Dali::DevelWindow::MoveCompletedSignal()
*/
MoveCompletedSignalType mMoveCompletedSignal;
ResizeCompletedSignalType mResizeCompletedSignal;
InsetsChangedSignalType mInsetsChangedSignal;
+ PointerConstraintsSignalType mPointerConstraintsSignal;
Dali::KeyEvent mLastKeyEvent;
Dali::TouchEvent mLastTouchEvent;
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.
*/
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));
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);
}
}
}
}
+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);
*/
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.
*/