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

View for displaying surfaces. More...

+ Inheritance diagram for LSurfaceView:

Public Member Functions

 LSurfaceView (LSurface *surface, LView *parent=nullptr) noexcept
 LSurfaceView class constructor. More...
 
 ~LSurfaceView () noexcept
 LSurfaceView class destructor. More...
 
LSurfacesurface () const noexcept
 Gets the LSurface associated with the view. More...
 
bool primary () const noexcept
 Check if the view is a primary view. More...
 
void setPrimary (bool primary) noexcept
 Set the view as a primary view. More...
 
bool customPosEnabled () const noexcept
 Check if custom position is enabled for the view. More...
 
void enableCustomPos (bool enable) noexcept
 Enable or disable custom position for the view. More...
 
bool customInputRegionEnabled () const noexcept
 Check if custom input region is enabled for the view. More...
 
void enableCustomInputRegion (bool enabled) noexcept
 Enable or disable custom input region for the view. More...
 
void setCustomPos (const LPoint &pos) noexcept
 Set a custom position for the view. More...
 
void setCustomPos (Int32 x, Int32 y) noexcept
 Set a custom position for the view. More...
 
const LPointcustomPos () const noexcept
 Gets the custom position set for the view. More...
 
void setCustomInputRegion (const LRegion *region) noexcept
 Set a custom input region for the view. More...
 
const LRegioncustomInputRegion () const noexcept
 Gets the custom input region set for the view. More...
 
void enableCustomTranslucentRegion (bool enabled) noexcept
 Enable or disable the custom translucent region for the view. More...
 
bool customTranslucentRegionEnabled () const noexcept
 Check if the custom translucent region is enabled for the view. More...
 
void setCustomTranslucentRegion (const LRegion *region) noexcept
 Set a custom translucent region for the view. More...
 
const LRectFsrcRect () const
 Gets the source rect of the surface, equivalent to LSurface::srcRect(). More...
 
void enableAlwaysMapped (bool enabled) noexcept
 Ignore the LSurface::mapped() state. More...
 
bool alwaysMappedEnabled () const noexcept
 
virtual bool nativeMapped () const noexcept override
 Tells whether the view should be rendered. More...
 
virtual const LPointnativePos () const noexcept override
 Gets the position of the view without any transformations applied. More...
 
virtual const LSizenativeSize () const noexcept override
 Gets the size of the view without any transformations applied. More...
 
virtual Float32 bufferScale () const noexcept override
 Gets the scale of the view buffer content. More...
 
virtual void enteredOutput (LOutput *output) noexcept override
 Notifies that portion of the view is visible on the given output. More...
 
virtual void leftOutput (LOutput *output) noexcept override
 Notifies that the view is no longer visible on the given output. More...
 
virtual const std::vector< LOutput * > & outputs () const noexcept override
 Gets a vector of output pointers on which the view is currently visible. More...
 
virtual void requestNextFrame (LOutput *output) noexcept override
 Notifies that the view has been rendered on the given output. More...
 
virtual const LRegiondamage () const noexcept override
 Gets the region within the view rect that needs to be repainted. More...
 
virtual const LRegiontranslucentRegion () const noexcept override
 Gets the current translucent region. More...
 
virtual const LRegionopaqueRegion () const noexcept override
 Gets the current opaque region. More...
 
virtual const LRegioninputRegion () const noexcept override
 Gets the current input region. More...
 
virtual void paintEvent (const PaintEventParams &params) noexcept override
 Requests to paint a region of the view to the current framebuffer. More...
 
- Public Member Functions inherited from LView
 LView (UInt32 type, bool renderable, LView *parent) noexcept
 Construct an LView object. More...
 
 ~LView () noexcept
 Destructor for the LView class. More...
 
void enablePointerEvents (bool enabled) noexcept
 Toggles pointer events. More...
 
bool pointerEventsEnabled () const noexcept
 Checks if pointer events are enabled. More...
 
bool pointerIsOver () const noexcept
 Checks if the view has pointer focus. More...
 
void enableBlockPointer (bool enabled) noexcept
 Toggles blocking pointer events to views behind the view's input region. More...
 
bool blockPointerEnabled () const noexcept
 Checks if blocking of pointer events is enabled. More...
 
void enableKeyboardEvents (bool enabled) noexcept
 Toggles keyboard events. More...
 
bool keyboardEventsEnabled () const noexcept
 Checks if keyboard events are enabled. More...
 
void enableTouchEvents (bool enabled) noexcept
 Toggles touch events. More...
 
bool touchEventsEnabled () const noexcept
 Checks if touch events are enabled. More...
 
void enableBlockTouch (bool enabled) noexcept
 Toggles blocking touch events to views behind the view's input region. More...
 
bool blockTouchEnabled () const noexcept
 Checks if blocking of touch events to views behind the view's input region is enabled. More...
 
void damageAll () noexcept
 Forces a complete repaint of the view in the next rendering frame. More...
 
LScenescene () const noexcept
 Gets the scene in which this view is currently embedded. More...
 
bool isLScene () const noexcept
 Checks if the view is an LScene::mainView(). More...
 
LSceneViewparentSceneView () const noexcept
 Gets the closest parent LSceneView. More...
 
UInt32 type () const noexcept
 Gets the identifier for the type of view. More...
 
bool isRenderable () const noexcept
 Checks if the view is renderable. More...
 
void repaint () const noexcept
 Schedules a repaint for all outputs where this view is currently visible. More...
 
LViewparent () const noexcept
 Gets the parent of the view. More...
 
void setParent (LView *view) noexcept
 Sets the new parent for the view and insert it at the end of its children list. More...
 
void insertAfter (LView *prev) noexcept
 Inserts the view after the specified 'prev' view. More...
 
const std::list< LView * > & children () const noexcept
 Children views. More...
 
void enableParentOffset (bool enabled) noexcept
 Toggles the parent position offset. More...
 
bool parentOffsetEnabled () const noexcept
 Checks if pos() includes the parent's position. More...
 
const LPointpos () const noexcept
 Gets the current position of the view with applied transformations. More...
 
const LSizesize () const noexcept
 Gets the current size of the view with applied transformations. More...
 
void enableClipping (bool enabled) noexcept
 Toggles the use of the clippingRect() property. More...
 
bool clippingEnabled () const noexcept
 Checks if the view is currently being clipped to the clippingRect() property. More...
 
void setClippingRect (const LRect &rect) noexcept
 Sets a custom clipping rect. More...
 
const LRectclippingRect () const noexcept
 Gets the clipping rect set with setClippingRect(). More...
 
void enableParentClipping (bool enabled) noexcept
 Toggles parent clipping. More...
 
bool parentClippingEnabled () const noexcept
 Checks if the view is clipped to the parent view rect. More...
 
void enableScaling (bool enabled) noexcept
 Toggles the use of the scalingVector(). More...
 
bool scalingEnabled () const noexcept
 Checks if the scalingVector() is enabled. More...
 
void setScalingVector (const LSizeF &scalingVector) noexcept
 Sets the scalingVector() property. More...
 
const LSizeFscalingVector (bool forceIgnoreParent=false) const noexcept
 Gets the scaling vector. More...
 
void enableParentScaling (bool enabled) noexcept
 Toggles the scaling of size and position by the parent's scaling vector. More...
 
bool parentScalingEnabled () const noexcept
 Checks if the size and position are scaled by the parent's scalingVector(). More...
 
void setVisible (bool visible) noexcept
 Toggles the view visibility. More...
 
bool visible () const noexcept
 Checks if the view is marked as visible. More...
 
bool mapped () const noexcept
 Checks if the view should be rendered, taking into consideration several conditions. More...
 
void setOpacity (Float32 opacity) noexcept
 Set the view opacity. More...
 
Float32 opacity (bool forceIgnoreParent=false) const noexcept
 Gets the view opacity. More...
 
void enableParentOpacity (bool enabled) noexcept
 Toggles the use of the parent's opacity. More...
 
bool parentOpacityEnabled () const noexcept
 Checks if the view's opacity is multiplied by its parent's opacity. More...
 
void enableForceRequestNextFrame (bool enabled) noexcept
 Toggles forcing triggering the requestNextFrame() event. More...
 
bool forceRequestNextFrameEnabled () const noexcept
 Checks if forcing requestNextFrame() is enabled. More...
 
void setBlendFunc (const LBlendFunc &blendFunc) noexcept
 Sets a custom alpha/color blending function for the view. More...
 
const LBlendFuncblendFunc () const noexcept
 Gets the blending function set with setBlendFunc(). More...
 
void enableAutoBlendFunc (bool enabled) noexcept
 Toggles the automatic blend function adjustment. More...
 
bool autoBlendFuncEnabled () const noexcept
 Checks whether the automatic blend function adjustment is enabled. More...
 
void setColorFactor (const LRGBAF &colorFactor) noexcept
 Set the color factor. More...
 
const LRGBAFcolorFactor () const noexcept
 Gets the color factor. More...
 
LBox boundingBox () const noexcept
 Gets the bounding box of the view and all its mapped children. More...
 
virtual void pointerEnterEvent (const LPointerEnterEvent &event)
 Handles a pointer enter event within the view. More...
 
virtual void pointerMoveEvent (const LPointerMoveEvent &event)
 Handle a pointer move event within the view. More...
 
virtual void pointerLeaveEvent (const LPointerLeaveEvent &event)
 Handle a pointer leave event within the view. More...
 
virtual void pointerButtonEvent (const LPointerButtonEvent &event)
 Handle a pointer button event within the view. More...
 
virtual void pointerScrollEvent (const LPointerScrollEvent &event)
 Handle a pointer scroll event within the view. More...
 
virtual void pointerSwipeBeginEvent (const LPointerSwipeBeginEvent &event)
 Handle a pointer swipe begin event within the view. More...
 
virtual void pointerSwipeUpdateEvent (const LPointerSwipeUpdateEvent &event)
 Handle a pointer swipe update event within the view. More...
 
virtual void pointerSwipeEndEvent (const LPointerSwipeEndEvent &event)
 Handle a pointer swipe end event within the view. More...
 
virtual void pointerPinchBeginEvent (const LPointerPinchBeginEvent &event)
 Handle a pointer pinch begin event within the view. More...
 
virtual void pointerPinchUpdateEvent (const LPointerPinchUpdateEvent &event)
 Handle a pointer pinch update event within the view. More...
 
virtual void pointerPinchEndEvent (const LPointerPinchEndEvent &event)
 Handle a pointer pinch end event within the view. More...
 
virtual void pointerHoldBeginEvent (const LPointerHoldBeginEvent &event)
 Handle a pointer hold begin event within the view. More...
 
virtual void pointerHoldEndEvent (const LPointerHoldEndEvent &event)
 Handle a pointer hold end event within the view. More...
 
virtual void keyEvent (const LKeyboardKeyEvent &event)
 Handle the key event within the view. More...
 
virtual void touchDownEvent (const LTouchDownEvent &event)
 Handle a touch down event within the view. More...
 
virtual void touchMoveEvent (const LTouchMoveEvent &event)
 Handle a touch move event within the view. More...
 
virtual void touchUpEvent (const LTouchUpEvent &event)
 Handle a touch up event within the view. More...
 
virtual void touchFrameEvent (const LTouchFrameEvent &event)
 Handle a touch frame event within the view. More...
 
virtual void touchCancelEvent (const LTouchCancelEvent &event)
 Handle a touch cancel event within the view. 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 LView
enum  Type : UInt8
 Types of views included with Louvre. 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...
 

Detailed Description

View for displaying surfaces.

The LSurfaceView class can be used to display client surfaces on a scene. By default, it inherits the damage, input, translucent, and opaque regions, as well as the surface position from the LSurface.

To override any of these properties, you can use these specific methods:

An LSurface can have multiple views, but only views with the primary() property set to true will clear its damage when requestNextFrame() is called and also send LSurface::sendOutputEnterEvent() and LSurface::sendOutputLeaveEvent() to its client. Use the setPrimary() method to set the primary property of a view.

Attention
The view should always be destroyed before its surface.

Constructor & Destructor Documentation

◆ LSurfaceView()

LSurfaceView ( LSurface surface,
LView parent = nullptr 
)
noexcept

LSurfaceView class constructor.

Parameters
surfacePointer to the LSurface associated with this view.
parentPointer to the parent LView. Default value is nullptr.

◆ ~LSurfaceView()

~LSurfaceView ( )
noexcept

LSurfaceView class destructor.

Member Function Documentation

◆ surface()

LSurface* surface ( ) const
inlinenoexcept

Gets the LSurface associated with the view.

Returns
Pointer to the LSurface associated with the view.

◆ primary()

bool primary ( ) const
inlinenoexcept

Check if the view is a primary view.

Only primary views will clear their damage when requestNextFrame() is called. The default value is true.

Returns
True if the view is a primary view, false otherwise.

◆ setPrimary()

void setPrimary ( bool  primary)
inlinenoexcept

Set the view as a primary view.

Only primary views will clear their damage when requestNextFrame() is called.

Parameters
primaryTrue to set the view as a primary view, false otherwise.

◆ customPosEnabled()

bool customPosEnabled ( ) const
inlinenoexcept

Check if custom position is enabled for the view.

If enabled, nativePos() will return the position set with setCustomPos() instead of the surface position. The default value is false.

Returns
True if custom position is enabled, false otherwise.

◆ enableCustomPos()

void enableCustomPos ( bool  enable)
inlinenoexcept

Enable or disable custom position for the view.

If enabled, nativePos() will return the position set with setCustomPos() instead of the surface position.

Parameters
enableTrue to enable custom position, false to disable.

◆ customInputRegionEnabled()

bool customInputRegionEnabled ( ) const
inlinenoexcept

Check if custom input region is enabled for the view.

If enabled, inputRegion() will return the input region set with setCustomInputRegion() instead of the surface input region. The default value is false.

Returns
True if custom input region is enabled, false otherwise.

◆ enableCustomInputRegion()

void enableCustomInputRegion ( bool  enabled)
inlinenoexcept

Enable or disable custom input region for the view.

If enabled, inputRegion() will return the input region set with setCustomInputRegion() instead of the surface input region.

Parameters
enabledTrue to enable custom input region, false to disable.

◆ setCustomPos() [1/2]

void setCustomPos ( const LPoint pos)
inlinenoexcept

Set a custom position for the view.

This method allows you to set a custom position for the view, overriding the surface position.

Parameters
posThe custom position as an LPoint object.

◆ setCustomPos() [2/2]

void setCustomPos ( Int32  x,
Int32  y 
)
inlinenoexcept

Set a custom position for the view.

This method allows you to set a custom position for the view, overriding the surface position.

Parameters
xThe X coordinate of the custom position.
yThe Y coordinate of the custom position.

◆ customPos()

const LPoint& customPos ( ) const
inlinenoexcept

Gets the custom position set for the view.

Returns
The custom position as an LPoint object.

◆ setCustomInputRegion()

void setCustomInputRegion ( const LRegion region)
inlinenoexcept

Set a custom input region for the view.

This method allows you to set a custom input region for the view, overriding the surface input region.

Parameters
regionPointer to the custom input region as an LRegion object.

◆ customInputRegion()

const LRegion* customInputRegion ( ) const
inlinenoexcept

Gets the custom input region set for the view.

Returns
Pointer to the custom input region as an LRegion object.

◆ enableCustomTranslucentRegion()

void enableCustomTranslucentRegion ( bool  enabled)
inlinenoexcept

Enable or disable the custom translucent region for the view.

If enabled, the view will use the custom translucent region set with setCustomTranslucentRegion() instead of the surface translucent region.

Parameters
enabledTrue to enable the custom translucent region, false to disable.

◆ customTranslucentRegionEnabled()

bool customTranslucentRegionEnabled ( ) const
inlinenoexcept

Check if the custom translucent region is enabled for the view.

Returns
True if the custom translucent region is enabled, false otherwise.

◆ setCustomTranslucentRegion()

void setCustomTranslucentRegion ( const LRegion region)
inlinenoexcept

Set a custom translucent region for the view.

This method allows you to set a custom translucent region for the view, overriding the surface translucent region.

Parameters
regionPointer to the custom translucent region as an LRegion object.

◆ srcRect()

const LRectF & srcRect ( ) const

Gets the source rect of the surface, equivalent to LSurface::srcRect().

◆ enableAlwaysMapped()

void enableAlwaysMapped ( bool  enabled)
inlinenoexcept

Ignore the LSurface::mapped() state.

If enabled nativeMapped() will return true even if the surface is unmapped as long as it contains a texture.

Disabled by default.

◆ alwaysMappedEnabled()

bool alwaysMappedEnabled ( ) const
inlinenoexcept

◆ nativeMapped()

bool nativeMapped ( ) const
overridevirtualnoexcept

Tells whether the view should be rendered.

Returns
true if the view should be rendered without considering visible(), otherwise false.

Implements LView.

◆ nativePos()

const LPoint & nativePos ( ) const
overridevirtualnoexcept

Gets the position of the view without any transformations applied.

Must return the position of the view in compositor-global coordinates.

Returns
The position of the view as an LPoint object.

Implements LView.

◆ nativeSize()

const LSize & nativeSize ( ) const
overridevirtualnoexcept

Gets the size of the view without any transformations applied.

Must return the size of the view in surface coordinates.

Returns
The size of the view as an LSize object.

Implements LView.

◆ bufferScale()

Float32 bufferScale ( ) const
overridevirtualnoexcept

Gets the scale of the view buffer content.

This property is primarily used by views that contain a buffer like for example the LSceneView, LSurfaceView and LTextureView types.

Returns
The buffer scale as an Int32 value.

Implements LView.

◆ enteredOutput()

void enteredOutput ( LOutput output)
overridevirtualnoexcept

Notifies that portion of the view is visible on the given output.

This method is invoked by a LScene when the view's rect intersects an output.

Parameters
outputThe LOutput where the view is visible.

Implements LView.

◆ leftOutput()

void leftOutput ( LOutput output)
overridevirtualnoexcept

Notifies that the view is no longer visible on the given output.

This method is invoked by a LScene when the view's rect no longer intersects an output.

Parameters
outputThe LOutput from which the view is no longer visible.

Implements LView.

◆ outputs()

const std::vector< LOutput * > & outputs ( ) const
overridevirtualnoexcept

Gets a vector of output pointers on which the view is currently visible.

Must return a vector of output pointers where the view is currently visible.
Use the enteredOutput() and leftOutput() methods to update the vector.

Returns
A reference to a vector of LOutput pointers representing the outputs where the view is visible.

Implements LView.

◆ requestNextFrame()

void requestNextFrame ( LOutput output)
overridevirtualnoexcept

Notifies that the view has been rendered on the given output.

This method is called by the closest parent scene view and should be used to clear the previous view damage or update its content.
If forceRequestNextFrameEnabled() is true, this method is always called.

Parameters
outputThe LOutput on which the view is rendered.

Implements LView.

◆ damage()

const LRegion * damage ( ) const
overridevirtualnoexcept

Gets the region within the view rect that needs to be repainted.

The region rects are specified in surface coordinates within the view, without any scaling, clipping, or offset transformations applied.

It should be cleared after requestNextFrame() is called.

If nullptr is returned, the entire view rect will be considered damaged.

If the view has no damage, simply pass an empty LRegion (not nullptr).

Returns
A pointer to the LRegion specifying the damaged area within the view, or nullptr if the entire view rect is damaged.

Implements LView.

◆ translucentRegion()

const LRegion * translucentRegion ( ) const
overridevirtualnoexcept

Gets the current translucent region.

The region must be specified in surface-local coordinates, without any scaling, clipping, or offset transformations applied.

If nullptr is returned, the entire view rect will be considered translucent.

Implements LView.

◆ opaqueRegion()

const LRegion * opaqueRegion ( ) const
overridevirtualnoexcept

Gets the current opaque region.

The region must be specified in surface-local coordinates without any scaling, clipping, or offset transformations applied.

If nullptr is returned, the inverse of the translucent region will be considered opaque.

Note
You could only specify the translucent region.

Implements LView.

◆ inputRegion()

const LRegion * inputRegion ( ) const
overridevirtualnoexcept

Gets the current input region.

Region within the view rect that can receive pointer and touch events.

The region must be specified in surface-local coordinates without any scaling, clipping, or offset transformations applied.

If nullptr is returned, the entire view will receive input.

Implements LView.

◆ paintEvent()

void paintEvent ( const PaintEventParams params)
overridevirtualnoexcept

Requests to paint a region of the view to the current framebuffer.

This method is used by the closest parent LSceneView to request the view to paint a specified region on the current framebuffer. Painting can be performed using the provided LPainter object.

Note
Using LPainter is optional.

Implements LView.