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

Subsurface role for surfaces. More...

+ Inheritance diagram for LSubsurfaceRole:

Public Member Functions

 LSubsurfaceRole (const void *params) noexcept
 Constructor of the LSubsurfaceRole class. More...
 
 ~LSubsurfaceRole ()
 Destructor of the LSubsurfaceRole class. More...
 
bool isSynced () const noexcept
 Current mode. More...
 
const LPointlocalPos () const noexcept
 Offset in surface 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...
 

Virtual Methods

virtual const LPointrolePos () const override
 Position of the subsurface according to the role. More...
 
virtual void localPosChanged ()
 Change of offset. More...
 
virtual void syncModeChanged ()
 Change of mode. More...
 
virtual void placedAbove (LSurface *sibling)
 Place above. More...
 
virtual void placedBelow (LSurface *sibling)
 Place below. 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 void handleSurfaceBufferAttach (wl_resource *buffer, Int32 x, Int32 y)
 Notifies a new surface buffer attachment. More...
 
virtual void handleSurfaceOffset (Int32 x, Int32 y)
 Notifies a surface buffer offset change. 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

Subsurface role for surfaces.

LSubsurfaceRole surfaces are always children of other surfaces and are positioned relative to their parent surface. They are meant to be treated and composited as if they were part of their parent surface, for example, for displaying a video frame within a web browser window.

The Subsurface role is part of the Wayland protocol.

Ordering

Clients can request to modify the order in which they are stacked relative to their parent surface or other sibling surfaces. See placedAbove() and placedBelow(). Louvre automatically updates the LCompositor::surfaces() list, keeping the order and also triggering the LSurface::orderChanged() event.

Modes

Subsurfaces can operate in two modes:

Synchronous Mode

In this mode, changes to the subsurface, such as its position, are applied exclusively when its parent performs a commit. This mode is used by clients to synchronize the animation or movement of multiple subsurfaces. The library keeps track of changes and applies them when the parent performs a commit.

Asynchronous Mode

In this mode, subsurface changes are applied independently of the commits of its parent.

Note
This documentation is for educational purposes only. Louvre handles all of this internally for you.

Constructor & Destructor Documentation

◆ LSubsurfaceRole()

LSubsurfaceRole ( const void *  params)
noexcept

Constructor of the LSubsurfaceRole class.

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

◆ ~LSubsurfaceRole()

~LSubsurfaceRole ( )
inline

Destructor of the LSubsurfaceRole class.

Invoked after LCompositor::onAnticipatedObjectDestruction().

Member Function Documentation

◆ isSynced()

bool isSynced ( ) const
inlinenoexcept

Current mode.

Returns
true if in synchronous mode, false otherwise.

◆ localPos()

const LPoint& localPos ( ) const
inlinenoexcept

Offset in surface coordinates.

The offset relative to the top-left corner of the parent surface in surface coordinates.

◆ rolePos()

virtual const LPoint& rolePos ( ) const
overridevirtual

Position of the subsurface according to the role.

The default implementation of rolePos() positions the subsurface relative to its parent rolePos() by adding the offset given by localPos().

Default implementation

{
if (surface()->parent())
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
const LPoint & localPos() const noexcept
Offset in surface coordinates.
Definition: LSubsurfaceRole.h:76
virtual const LPoint & rolePos() const override
Position of the subsurface according to the role.
LSurface * parent() const noexcept
Parent surface.
Definition: LSurface.cpp:481
const LPoint & rolePos() const
Role position.
Definition: LSurface.cpp:326
LPointTemplate< Int32 > LPoint
2D vector of 32 bits integers
Definition: LNamespaces.h:250

Implements LBaseSurfaceRole.

◆ localPosChanged()

virtual void localPosChanged ( )
virtual

Change of offset.

Default implementation

{
}
virtual void localPosChanged()
Change of offset.
void repaintOutputs() noexcept
Repaints the intersected outputs.
Definition: LSurface.cpp:196

◆ syncModeChanged()

virtual void syncModeChanged ( )
virtual

Change of mode.

Default implementation

{
/* No default implementation */
}
virtual void syncModeChanged()
Change of mode.

◆ placedAbove()

virtual void placedAbove ( LSurface sibling)
virtual

Place above.

Note
Louvre automatically maintains the hierarchical order of LCompositor::surfaces().

Default Implementation

void LSubsurfaceRole::placedAbove(LSurface *sibling)
{
L_UNUSED(sibling);
}
virtual void placedAbove(LSurface *sibling)
Place above.

◆ placedBelow()

virtual void placedBelow ( LSurface sibling)
virtual

Place below.

Note
Louvre automatically maintains the hierarchical order of LCompositor::surfaces().

Default Implementation

void LSubsurfaceRole::placedAbove(LSurface *sibling)
{
L_UNUSED(sibling);
}