Louvre  v2.13.0-1
C++ library for Wayland compositors
Public Member Functions | List of all members
LCursorRole Class Reference

Cursor role for surfaces. More...

+ Inheritance diagram for LCursorRole:

Public Member Functions

 LCursorRole (const void *params) noexcept
 Constructor of the LCursorRole class. More...
 
 ~LCursorRole ()
 Destructor of the LCursorRole class. More...
 
virtual const LPointrolePos () const override
 Position of the surface given the role. More...
 
virtual void hotspotChanged ()
 Notifies a hotspot change. More...
 
const LPointhotspot () const noexcept
 Cursor hotspot in surface coordinates. More...
 
const LPointhotspotB () const noexcept
 Cursor hotspot in buffer coordinates. More...
 
- Public Member Functions inherited from LBaseSurfaceRole
 LBaseSurfaceRole (LFactoryObject::Type type, LResource *resource, LSurface *surface, UInt32 roleId) noexcept
 Constructor of LBaseSurfaceRole class. More...
 
 ~LBaseSurfaceRole ()
 The LBaseSurfaceRole class destructor. More...
 
virtual LOutputexclusiveOutput () const
 The output to which the surface should be constrained. More...
 
UInt32 roleId () const noexcept
 Role ID. More...
 
LSurfacesurface () const noexcept
 Returns the surface that has acquired the role provided in the constructor. More...
 
LResourceresource () const
 Returns the Wayland resource for this role given in the constructor. More...
 
LClientclient () const noexcept
 Client owner of the surface role. More...
 
- Public Member Functions inherited from LFactoryObject
Type factoryObjectType () const noexcept
 Gets the base factory object type. 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

- Public Types inherited from LBaseSurfaceRole
enum  CommitOrigin
 Commit origin. More...
 
- Public Types inherited from LFactoryObject
enum class  Type : Int32
 Base factory object types. More...
 
- Protected Member Functions inherited from LBaseSurfaceRole
virtual bool acceptCommitRequest (CommitOrigin origin)
 Asks if the surface commit should be processed. More...
 
virtual void handleSurfaceBufferAttach (wl_resource *buffer, Int32 x, Int32 y)
 Notifies a new surface buffer attachment. More...
 
virtual void handleParentCommit ()
 Notifies a parent surface commit. More...
 
virtual void handleParentMappingChange ()
 Notifies when the mapping state of the parent surface changes. More...
 
virtual void handleParentChange ()
 Notifies when the parent surface changes. More...
 
- 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...
 
- Protected Attributes inherited from LBaseSurfaceRole
LPoint m_rolePos
 Variable that stores the surface position given the role. More...
 

Detailed Description

Cursor role for surfaces.

Clients create this role when they want to assign the compositor cursor texture and hotspot.
Instead of rendering this surface, the LCursor class should be employed, which displays the cursor using hardware composition, which is more efficient.

When clients want to assign the cursor, they trigger the LPointer::setCursorRequest(), providing the cursor in the form of an LClientCursor. That class serves as a wrapper for this role, and when assigned to LCursor with LCursor::setCursor(), it automatically updates its buffer, size, hotspot, and visibility.

See also
LPointer::setCursorRequest()

Constructor & Destructor Documentation

◆ LCursorRole()

LCursorRole ( const void *  params)
noexcept

Constructor of the LCursorRole class.

Parameters
paramsInternal parameters provided in LCompositor::createObjectRequest().

◆ ~LCursorRole()

Destructor of the LCursorRole class.

Invoked after LCompositor::onAnticipatedObjectDestruction().

Member Function Documentation

◆ rolePos()

virtual const LPoint& rolePos ( ) const
overridevirtual

Position of the surface given the role.

The cursor position given the role is calculated by subtracting the hotspot from LSurface::pos().
This position is generally not used since the cursor is usually rendered using the LCursor class.
However, it could be useful in cases where you do not want to use the LCursor class.

Default implementation

{
return m_rolePos;
}
LSurface * surface() const noexcept
Returns the surface that has acquired the role provided in the constructor.
Definition: LBaseSurfaceRole.h:117
LPoint m_rolePos
Variable that stores the surface position given the role.
Definition: LBaseSurfaceRole.h:144
virtual const LPoint & rolePos() const override
Position of the surface given the role.
const LPoint & hotspot() const noexcept
Cursor hotspot in surface coordinates.
Definition: LCursorRole.h:66
const LPoint & pos() const noexcept
Position given by the compositor.
Definition: LSurface.cpp:321
LPointTemplate< Int32 > LPoint
2D vector of 32 bits integers
Definition: LNamespaces.h:250

Implements LBaseSurfaceRole.

◆ hotspotChanged()

virtual void hotspotChanged ( )
virtual

Notifies a hotspot change.

Default implementation

{
/* No default implementation */
}
virtual void hotspotChanged()
Notifies a hotspot change.

◆ hotspot()

const LPoint& hotspot ( ) const
inlinenoexcept

Cursor hotspot in surface coordinates.

◆ hotspotB()

const LPoint& hotspotB ( ) const
inlinenoexcept

Cursor hotspot in buffer coordinates.