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

An XCursor icon. More...

Public Member Functions

 ~LXCursor ()=default
 Destructor. More...
 
const LTexturetexture () const noexcept
 Gets the cursor's texture. More...
 
const LPointhotspotB () const noexcept
 Gets the cursor's hotspot in buffer coordinates. More...
 

Static Public Member Functions

static LXCursorload (const char *cursor, const char *theme=NULL, Int32 suggestedSize=64) noexcept
 Load an XCursor pixmap. More...
 

Detailed Description

An XCursor icon.

XCursor icons are widely used for cursor themes in Linux.
This class facilitates loading icons installed on the system and retrieving their hotspot and texture, which can then be applied to LCursor.

Example usage:

LXCursor *handCursor { LXCursor::load("hand2", "Adwaita", 64) };
if (handCursor)
cursor()->setTextureB(handCursor->texture(),
handCursor->hotspotB());
void setTextureB(const LTexture *texture, const LPointF &hotspot) noexcept
Sets the cursor texture.
Definition: LCursor.cpp:162
static LXCursor * load(const char *cursor, const char *theme=NULL, Int32 suggestedSize=64) noexcept
Load an XCursor pixmap.
Definition: LXCursor.cpp:7
LCursor * cursor() noexcept
Gets the compositor's cursor.
Definition: LCompositor.cpp:45

Constructor & Destructor Documentation

◆ ~LXCursor()

~LXCursor ( )
default

Destructor.

Release the icon resources, including the texture.

Member Function Documentation

◆ load()

LXCursor * load ( const char *  cursor,
const char *  theme = NULL,
Int32  suggestedSize = 64 
)
staticnoexcept

Load an XCursor pixmap.

Loads an XCursor that matches the specified name and theme.

Parameters
cursorName of the XCursor to load.
themeName of the cursor theme. Pass NULL if you don't want to specify a theme.
suggestedSizeSuggested buffer size (width or height) of the pixmap. Returns the variant of the pixmap with closest dimensions to the specified one.
Returns
If an XCursor matching the parameters is found, returns an instance of the LXCursor class, which stores the cursor's hotspot, and texture. Otherwise, it returns nullptr.

◆ texture()

const LTexture* texture ( ) const
inlinenoexcept

Gets the cursor's texture.

◆ hotspotB()

const LPoint& hotspotB ( ) const
inlinenoexcept

Gets the cursor's hotspot in buffer coordinates.