Louvre
v2.12.0-1
C++ library for Wayland compositors
|
Utility class for rendering cursors. More...
Public Member Functions | |
void | setPos (const LPointF &pos) noexcept |
Sets the cursor position. More... | |
void | setPos (Float32 x, Float32 y) noexcept |
Set the cursor position. More... | |
const LPointF & | pos () const noexcept |
Gets the current cursor position in compositor-global coordinates. More... | |
void | move (Float32 dx, Float32 dy) noexcept |
Moves the cursor. More... | |
void | move (const LPointF &delta) noexcept |
Moves the cursor. More... | |
const LRect & | rect () const noexcept |
Gets the cursor rect on the screen. More... | |
void | setSize (const LSizeF &size) noexcept |
Sets the cursor size. More... | |
void | setVisible (bool state) noexcept |
Toggles the cursor visibility. More... | |
bool | visible () const noexcept |
Checks if the cursor is visible. More... | |
void | setCursor (const LClientCursor &clientCursor) noexcept |
Assigns an LClientCursor. More... | |
void | setCursor (const LXCursor *xcursor) noexcept |
Assigns an LXCursor. More... | |
const LClientCursor * | clientCursor () const noexcept |
Retrieves the client cursor set with setCursor(). More... | |
LTexture * | texture () const noexcept |
Gets the current cursor texture. More... | |
void | setTextureB (const LTexture *texture, const LPointF &hotspot) noexcept |
Sets the cursor texture. More... | |
void | useDefault () noexcept |
Restores the default cursor. More... | |
void | replaceDefaultB (const LTexture *texture, const LPointF &hotspot) noexcept |
Replaces Louvre's default cursor. More... | |
LTexture * | defaultTexture () const noexcept |
Gets the default cursor texture. More... | |
const LPointF & | defaultHotspotB () const noexcept |
Gets the default cursor hotspot. More... | |
LTexture * | defaultLouvreTexture () const noexcept |
Default Louvre's cursor texture. More... | |
void | setHotspotB (const LPointF &hotspot) noexcept |
Sets the cursor hotspot in buffer coordinates. More... | |
const LPointF & | hotspotB () const noexcept |
Gets the current cursor hotspot in buffer coordinates. More... | |
void | enable (LOutput *output, bool enable) noexcept |
Enables or disables LCursor for the specified output. More... | |
bool | enabled (LOutput *output) const noexcept |
Checks if LCursor is enabled for the specified output. More... | |
bool | hasHardwareSupport (const LOutput *output) const noexcept |
Checks if a given output supports hardware compositing. More... | |
void | enableHwCompositing (LOutput *output, bool enabled) noexcept |
Toggles hardware compositing for the specified output. More... | |
bool | hwCompositingEnabled (LOutput *output) const noexcept |
Checks if hardware compositing is enabled for the specified output. More... | |
const LRegion & | damage (LOutput *output) const noexcept |
Damaged region in compositor-global coordinates. More... | |
LOutput * | output () const noexcept |
Gets the current cursor output. More... | |
const std::vector< LOutput * > & | intersectedOutputs () const noexcept |
Vector of intersected outputs. More... | |
void | repaintOutputs (bool nonHardwareOnly=true) noexcept |
Repaint intersected outputs. More... | |
Public Member Functions inherited from LObject | |
LObject (const LObject &) noexcept | |
Copy constructor. More... | |
LObject & | operator= (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... | |
Utility class for rendering cursors.
The LCursor class is designed to make cursor rendering easier and take advantage of compositing properties of certain graphic backends to improve performance.
Some graphic backends, such as DRM, allow for hardware cursor compositing, which can improve performance by reducing the need to repaint an output every time the cursor changes position.
To check if an output supports hardware cursor compositing, use hasHardwareSupport().
If hardware compositing is not supported for a specific output, the cursor is rendered by Louvre using OpenGL after a paintGL() event (when needed). In such cases the damage region provided by damage() has to be repainted.
|
noexcept |
Sets the cursor position.
Sets the cursor position in compositor-global coordinates.
pos | The new cursor position. |
|
inlinenoexcept |
Gets the current cursor position in compositor-global coordinates.
Moves the cursor.
Adjusts the cursor position by a delta (dx, dy) in surface coordinates.
dx | Delta x in surface coordinates. |
dy | Delta y in surface coordinates. |
|
noexcept |
|
noexcept |
Sets the cursor size.
Sets the cursor size in surface coordinates. The texture and hotspot are automatically scaled, with the hotspot maintaining its proportion to the texture buffer size.
The initial cursor size is (24, 24).
size | The desired cursor size in surface coordinates. |
|
noexcept |
Toggles the cursor visibility.
state | true to set visible, false otherwise. |
|
noexcept |
Checks if the cursor is visible.
|
noexcept |
Assigns an LClientCursor.
While an LClientCursor is assigned, the cursor is automatically updated when the client updates its LCursorRole surface texture, hotspot, and visibility.
If the LClientCursor is destroyed while set, useDefault() is called and the cursor is set to visible.
clientCursor | The LClientCursor to assign. |
|
noexcept |
Assigns an LXCursor.
nullptr
is a no-op.
|
noexcept |
Retrieves the client cursor set with setCursor().
nullptr
otherwise.
|
noexcept |
Gets the current cursor texture.
nullptr
otherwise. Sets the cursor texture.
Assigns the texture and hotspot of the cursor. The texture size does not necessarily define the cursor size, see setSize().
texture | Texture to assign. |
hotspot | Cursor hotspot in buffer coordinates. |
|
noexcept |
Restores the default cursor.
Sets the cursor's texture and hotspot to the default values configured using replaceDefaultB().
The default texture initially matches defaultLouvreTexture() with a hotspot at (8, 8).
Replaces Louvre's default cursor.
This method allows you to replace the Louvre's default cursor texture and hotspot, which is set when useDefault() is called.
texture | The new texture to use as the default cursor, or nullptr to restore the default Louvre cursor. |
hotspot | The hotspot position for the new cursor in buffer coordinates. |
|
noexcept |
Gets the default cursor texture.
This method returns the texture that has been set using replaceDefaultB().
Initially, the default texture is the same as defaultLouvreTexture().
|
noexcept |
Gets the default cursor hotspot.
The hotspot that has been set using replaceDefaultB().
Initially set to (8, 8).
|
noexcept |
|
noexcept |
Sets the cursor hotspot in buffer coordinates.
The cursor hotspot is defined by coordinates relative to the origin of its buffer (upper left corner).
hotspot | The desired hotspot in buffer coordinates. |
|
noexcept |
Gets the current cursor hotspot in buffer coordinates.
|
noexcept |
|
noexcept |
|
noexcept |
Checks if a given output supports hardware compositing.
true
if hardware compositing is supported and false
otherwise.
|
noexcept |
Toggles hardware compositing for the specified output.
When disabled, Louvre will render the cursor using OpenGL after an LOutput::paintGL() event.
Hardware compositing is enabled by default if the output supports it, see hasHardwareSupport().
output | The output for which to enable or disable hardware compositing. |
enabled | Set to true to enable hardware compositing, or false to disable it. |
|
noexcept |
Checks if hardware compositing is enabled for the specified output.
false
if hasHardwareSupport() for the given output returns false
.output | The output to check. |
true
if hardware compositing is enabled for the given output, false
otherwise. Damaged region in compositor-global coordinates.
Provides the region that needs to be repainted when hardware compositing isn't supported or is disabled, allowing Louvre to properly render it after an LOutput::paintGL() event.
|
noexcept |
Gets the current cursor output.
Returns the output where the cursor is currently positioned.
|
noexcept |
Vector of intersected outputs.
Returns a vector of initialized outputs that intersect with the cursor's rect() property.
|
noexcept |
Repaint intersected outputs.
Invokes LOutput::repaint() for each output in the vector of intersected outputs.
nonHardwareOnly | If true , only repaints outputs that do not support hardware compositing. |