Louvre  v2.9.0-1
C++ library for Wayland compositors
Public Member Functions | List of all members
LTouchPoint Class Referencefinal

Touch point within a touch device. More...

+ Inheritance diagram for LTouchPoint:

Public Member Functions

Int32 id () const noexcept
 Gets the unique identifier of the touch point. More...
 
bool pressed () const noexcept
 Check if the touch point is currently being pressed. More...
 
LSurfacesurface () const noexcept
 Gets the surface currently being touched by this touch point. More...
 
const LTouchDownEventlastDownEvent () const noexcept
 Gets the last touch-down event sent with sendDownEvent(). More...
 
const LTouchMoveEventlastMoveEvent () const noexcept
 Gets the last touch move event sent with sendMoveEvent(). More...
 
const LTouchUpEventlastUpEvent () const noexcept
 Gets the last touch-up event sent with sendUpEvent(). More...
 
const LPointFpos () const noexcept
 Gets the position of the touch point assigned by the last touch-down or move event. More...
 
bool sendDownEvent (const LTouchDownEvent &event, LSurface *surface=nullptr) noexcept
 Mark the touch point as pressed. More...
 
bool sendMoveEvent (const LTouchMoveEvent &event) noexcept
 Notify the client about the movement of the touch point (if there is a surface assigned). More...
 
bool sendUpEvent (const LTouchUpEvent &event) noexcept
 Notify the client about the touch point being released (if there is a surface assigned). More...
 
- Public Member Functions inherited from LObject
 LObject (const LObject &) noexcept
 Copy constructor. More...
 
LObjectoperator= (const LObject &) noexcept
 Assignment operator (each object has its own individual LWeak reference count). More...
 
void setUserData (UIntPtr data) const noexcept
 Store an unsigned integer value/pointer. More...
 
UIntPtr userData () const noexcept
 Retrieves the stored unsigned integer value/pointer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from LObject
 LObject () noexcept=default
 Constructor of the LObject class. More...
 
virtual ~LObject () noexcept
 Destructor of the LObject class. More...
 
void notifyDestruction () noexcept
 Notifies the object destruction. More...
 

Detailed Description

Touch point within a touch device.

An instance of this class is created using LTouch::createOrGetTouchPoint() and is typically destroyed after calling LTouch::sendFrameEvent() when the touch point is no longer pressed, or when invoking LTouch::sendCancelEvent().

A touch point can be assigned to a single surface at a time or none at all. This assignment is performed using the sendDownEvent() method.

To gain a comprehensive understanding of touch events, please refer to the documentation of LTouch.

Note
When sending a touch-down or move event to a surface, ensure that the position is specified in local surface coordinates. Both LTouchDownEvent and LTouchMoveEvent contain a mutable variable named localPos. Be sure to set its value properly to the local surface coordinate before dispatching these events.

Member Function Documentation

◆ id()

Int32 id ( ) const
inlinenoexcept

Gets the unique identifier of the touch point.

Each touch point is assigned a unique identifier, ensuring that there are no two touch points with the same ID.

Returns
The unique identifier of the touch point.

◆ pressed()

bool pressed ( ) const
inlinenoexcept

Check if the touch point is currently being pressed.

This method indicates whether the touch point is in a pressed state. Initially, all touch points are marked as pressed upon creation. The state can change if either the sendDownEvent() or sendUpEvent() methods are invoked.

If LTouch::sendFrameEvent() is called and the touch point is no longer pressed, it will be automatically destroyed.

Returns
true if the touch point is currently pressed, false otherwise.

◆ surface()

LSurface* surface ( ) const
inlinenoexcept

Gets the surface currently being touched by this touch point.

The surface associated with this touch point is set using the sendDownEvent() method. If no surface is assigned to this touch point, this method returns nullptr.

Returns
A pointer to the LSurface being touched by this touch point, or nullptr if no surface is assigned.

◆ lastDownEvent()

const LTouchDownEvent& lastDownEvent ( ) const
inlinenoexcept

Gets the last touch-down event sent with sendDownEvent().

◆ lastMoveEvent()

const LTouchMoveEvent& lastMoveEvent ( ) const
inlinenoexcept

Gets the last touch move event sent with sendMoveEvent().

◆ lastUpEvent()

const LTouchUpEvent& lastUpEvent ( ) const
inlinenoexcept

Gets the last touch-up event sent with sendUpEvent().

◆ pos()

const LPointF& pos ( ) const
inlinenoexcept

Gets the position of the touch point assigned by the last touch-down or move event.

The position is represented in a coordinate space ranging from 0 to 1 for both the x and y axes.

Returns
A constant reference to the position of the touch point.

◆ sendDownEvent()

bool sendDownEvent ( const LTouchDownEvent event,
LSurface surface = nullptr 
)
noexcept

Mark the touch point as pressed.

If a surface is specified, the event is sent to that surface. If the surface is different from the current surface, the previous surface receives a touch-up event and a frame event. If the surface parameter is nullptr, it unsets the current surface. If the current assigned surface is destroyed, it is automatically unset.

Note
The LTouchDownEvent::localPos mutable variable must be set to represent the position in local surface coordinates.
Parameters
eventThe touch-down event with information about the touch point
surfaceThe surface to which the event should be sent. If nullptr, unsets the surface.
Returns
true on success, false if the IDs don't match.

◆ sendMoveEvent()

bool sendMoveEvent ( const LTouchMoveEvent event)
noexcept

Notify the client about the movement of the touch point (if there is a surface assigned).

Note
The LTouchMoveEvent::localPos mutable variable must be set to represent the position in local surface coordinates.
Parameters
eventThe touch move event containing information about the touch point movement.
Returns
true on success, false if the IDs don't match.

◆ sendUpEvent()

bool sendUpEvent ( const LTouchUpEvent event)
noexcept

Notify the client about the touch point being released (if there is a surface assigned).

If LTouch::sendFrameEvent() is called and the touch point is no longer pressed, it is automatically destroyed.

Parameters
eventThe touch-up event containing information about the touch point release.
Returns
true on success, false if the IDs don't match.