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

Exclusive zone within an LOutput. More...

+ Inheritance diagram for LExclusiveZone:

Public Types

using OnRectChangeCallback = std::function< void(LExclusiveZone *)>
 

Public Member Functions

 LExclusiveZone (LEdge edge, Int32 size, LOutput *output=nullptr) noexcept
 Constructor for LExclusiveZone. More...
 
 ~LExclusiveZone ()
 Destructor for LExclusiveZone. More...
 
void setEdgeAndSize (LEdge edge, Int32 size) noexcept
 Sets the edge and size simultaneously. More...
 
void setEdge (LEdge edge) noexcept
 Sets the edge of the output to which the exclusive zone is anchored. More...
 
void setSize (Int32 size) noexcept
 Sets the size of the exclusive zone. More...
 
void setOutput (LOutput *output) noexcept
 Sets the current output. More...
 
LOutputoutput () const noexcept
 Gets the current output. More...
 
LEdge edge () const noexcept
 Gets the current edge. More...
 
Int32 size () const noexcept
 Gets the exclusive zone size. More...
 
bool insertAfter (LExclusiveZone *zone) const
 Inserts this zone after the given zone in the LOutput::exclusiveZones() list. More...
 
LExclusiveZonenextZone () const noexcept
 Next exclusive zone in the LOutput::exclusiveZones() list. More...
 
LExclusiveZoneprevZone () const noexcept
 Previous exclusive zone in the LOutput::exclusiveZones() list. More...
 
const LRectrect () const noexcept
 Gets the calculated position and size of the exclusive zone in output-local surface coordinates. More...
 
void setOnRectChangeCallback (const OnRectChangeCallback &callback) noexcept
 Sets the rect change listener. More...
 
const OnRectChangeCallbackonRectChangeCallback () const noexcept
 Gets the callback set for rect changes. 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

- 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

Exclusive zone within an LOutput.

The LExclusiveZone class allows you to define a specific region relative to an LOutput edge to be considered exclusive.
It is primarily used by LLayerRole surfaces to prevent other elements from occupying their space, but it can also be utilized by custom compositor UI elements, such as a built-in panel.

When assigned to an output, exclusive zones affect LOutput::availableGeometry() and LOutput::exclusiveEdges(). These properties are used, for example, to properly position and resize LToplevelRole surfaces.

To define an exclusive zone, you need to specify the output(), the edge() it is anchored to, and the distance (size()) from that edge.
The rect() property will be updated to indicate the position and size of the exclusive zone within the output.

Multiple exclusive zones can be assigned to the same output. In such cases, the zones located at the beginning of the LOutput::exclusiveZones() list have preference, causing other zones to be moved/resized to prevent occlusion of the predominant ones.

Note
The order of the list can be modified using insertAfter().

The list order also determines the arrangement of multiple exclusive zones attached to the same edge. For example, if two exclusive zones are anchored to the top edge, the first one will be on top, and the second one will be closer to the center of the output.

You can also specify a callback function to be notified when an exclusive zone's rect() changes using the setOnRectChangeCallback() method.

Member Typedef Documentation

◆ OnRectChangeCallback

using OnRectChangeCallback = std::function<void(LExclusiveZone*)>

Callback function type used to handle the onRectChange() event.

Constructor & Destructor Documentation

◆ LExclusiveZone()

LExclusiveZone ( LEdge  edge,
Int32  size,
LOutput output = nullptr 
)
noexcept

Constructor for LExclusiveZone.

Initializes an exclusive zone with the specified edge, size, and output.

Parameters
edgeThe edge of the output to anchor the exclusive zone to.
sizeThe distance from the edge to define the exclusive zone.
outputThe output to assign the exclusive zone to.

◆ ~LExclusiveZone()

Destructor for LExclusiveZone.

Member Function Documentation

◆ setEdgeAndSize()

void setEdgeAndSize ( LEdge  edge,
Int32  size 
)
noexcept

Sets the edge and size simultaneously.

Each time the edge and/or size change, the rect() of all zones within the same output are recalculated.
This method allows you to change both parameters at once with a single update, which is more efficient.

Parameters
edgeThe edge of the output to anchor the exclusive zone to.
sizeThe distance from the edge to define the exclusive zone.

◆ setEdge()

void setEdge ( LEdge  edge)
noexcept

Sets the edge of the output to which the exclusive zone is anchored.

Accepts a single LEdge or LEdgeNone .
If set to LEdgeNone, the zone will not affect others, regardless of the value of size().

Parameters
edgeThe edge of the output to anchor the exclusive zone to.

◆ setSize()

void setSize ( Int32  size)
noexcept

Sets the size of the exclusive zone.

  • If the size is less than 0, the zone will not interact with others. In this case, rect() will be positioned at the given edge with a size of 0 and will expand to the orthogonal edges, or occupy the full output size if LEdgeNone is set.
  • If the size is 0, the zone will be affected (moved/resized) by other zones, but it will not affect others.
See also
setEdge()
Parameters
sizeThe distance from the edge to define the exclusive zone.

◆ setOutput()

void setOutput ( LOutput output)
noexcept

Sets the current output.

The zone is added at the end of the LOutput::exclusiveZones() list.

Parameters
outputThe output to assign the exclusive zone to, or nullptr to remove it from all outputs.

◆ output()

LOutput* output ( ) const
inlinenoexcept

Gets the current output.

Returns
The current output, or nullptr if not assigned.

◆ edge()

LEdge edge ( ) const
inlinenoexcept

Gets the current edge.

The edge the exclusive zone is anchored to, set with setEdge().

Returns
The current edge.

◆ size()

Int32 size ( ) const
inlinenoexcept

Gets the exclusive zone size.

The size of the exclusive zone, set with setSize().

Returns
The size of the exclusive zone.

◆ insertAfter()

bool insertAfter ( LExclusiveZone zone) const

Inserts this zone after the given zone in the LOutput::exclusiveZones() list.

This operation is only successful if both exclusive zones belong to the same output.

Parameters
zoneThe zone after which this zone should be inserted.
Returns
true if successful, false on failure.

◆ nextZone()

LExclusiveZone * nextZone ( ) const
noexcept

Next exclusive zone in the LOutput::exclusiveZones() list.

Returns
The next exclusive zone, or nullptr if no output is assigned or it is the last exclusive zone.

◆ prevZone()

LExclusiveZone * prevZone ( ) const
noexcept

Previous exclusive zone in the LOutput::exclusiveZones() list.

Returns
The previous exclusive zone, or nullptr if no output is assigned or it is the first exclusive zone.

◆ rect()

const LRect& rect ( ) const
inlinenoexcept

Gets the calculated position and size of the exclusive zone in output-local surface coordinates.

Note
If the output is nullptr, the rect is (0, 0, 0, 0).
Returns
The rect representing the position and size of the exclusive zone.

◆ setOnRectChangeCallback()

void setOnRectChangeCallback ( const OnRectChangeCallback callback)
inlinenoexcept

Sets the rect change listener.

This callback is triggered each time the exclusive zone rect() changes, for example, after modifying its parameters or when other zones change.

Parameters
callbackThe callback function to be called on rect changes.

◆ onRectChangeCallback()

const OnRectChangeCallback& onRectChangeCallback ( ) const
inlinenoexcept

Gets the callback set for rect changes.

Returns
The callback function set with setOnRectChangeCallback().