Louvre
v2.13.0-1
C++ library for Wayland compositors
|
Toplevel resize session utility. More...
Public Types | |
using | OnBeforeUpdateCallback = std::function< void(LToplevelResizeSession *)> |
Callback function type used in setOnBeforeUpdateCallback() More... | |
Public Member Functions | |
bool | start (const LEvent &triggeringEvent, LBitset< LEdge > edge, const LPoint &initDragPoint) |
Start the resizing session. More... | |
void | updateDragPoint (const LPoint &pos) |
Updates the drag point, causing the toplevel to move and/or resize. More... | |
const std::vector< LToplevelResizeSession * >::const_iterator | stop () |
Stops the resizing session. More... | |
void | setConstraints (const LMargins &constraints={LEdgeDisabled, LEdgeDisabled, LEdgeDisabled, LEdgeDisabled}) noexcept |
Sets the constraints for each side in compositor-global coordinates. More... | |
const LMargins & | constraints () const noexcept |
Retrieves the constraints set with setConstraints(). More... | |
void | setMinSize (const LSize &minSize) noexcept |
Sets a minimum size for the toplevel. More... | |
const LSize & | minSize () const noexcept |
Retrieves the minimum size set with setMinSize(). More... | |
void | setOnBeforeUpdateCallback (const OnBeforeUpdateCallback &callback) noexcept |
Sets a custom callback function to be triggered each time before updating the toplevel position or size. More... | |
LToplevelRole * | toplevel () const noexcept |
Retrieves the LToplevelRole associated with this session. More... | |
const LEvent & | triggeringEvent () const noexcept |
Retrieves the triggering event provided during the start of the session. More... | |
bool | isActive () const noexcept |
Checks if the session is currently active. More... | |
Toplevel resize session utility.
This class serves as a utility for handling interactive resize sessions for LToplevelRole surfaces.
Each LToplevelRole has an associated resize session instance LToplevelRole::resizeSession().
When a client triggers LToplevelRole::startResizeRequest(), the start() method should be invoked, providing the triggering event and edges of the request and an initial drag point, which could be the current position of the pointer (typically obtained via LCursor::pos()) or a touch point if triggered by a touch event. This also adds the session to the LSeat::toplevelResizeSessions() vector.
Subsequently, whenever the drag point changes, such as within an LPointer::pointerMoveEvent() or LTouch::touchMoveEvent(), updateDragPoint() should be called. The LSeat::toplevelResizeSessions() provides access to all active resize sessions, and the triggeringEvent() can be used to distinguish between pointer, touch or other kinds of sessions.
To dynamically modify constraints, a callback function can be specified with setOnBeforeUpdateCallback(), which is triggered each time before the toplevel position or size is updated. Within the callback function, setConstraints() can be used to update the constraints().
Finally, when the pointer button or touch point is released, the stop() method should be invoked to end the session and remove it from the LSeat::toplevelResizeSessions() vector. The stop() method also returns an iterator pointing to the next session in the vector which can be used in cases where the session is stopped while iterating through the vector.
using OnBeforeUpdateCallback = std::function<void(LToplevelResizeSession*)> |
Callback function type used in setOnBeforeUpdateCallback()
Start the resizing session.
triggeringEvent | The triggering event provided in LToplevelRole::startResizeRequest(). |
edge | The edge or corner provided in LToplevelRole::startResizeRequest() indicating the starting edge of the resize operation. |
initDragPoint | The initial pointer, touch, or other position at the start of the resizing operation. |
true
if the session successfully started, false
if the toplevel is already in a session. void updateDragPoint | ( | const LPoint & | pos | ) |
Updates the drag point, causing the toplevel to move and/or resize.
pos | The new position of the pointer or touch point. |
const std::vector< LToplevelResizeSession * >::const_iterator stop | ( | ) |
Stops the resizing session.
This method ends the current resizing session and removes it from the vector of active sessions.
|
inlinenoexcept |
Sets the constraints for each side in compositor-global coordinates.
constraints | The margins specifying the constraints for each side. Use LEdgeDisable to disable constraints on specific sides. |
|
inlinenoexcept |
Retrieves the constraints set with setConstraints().
|
inlinenoexcept |
Sets a minimum size for the toplevel.
minSize | The minimum size that the toplevel window can be resized to. |
|
inlinenoexcept |
Retrieves the minimum size set with setMinSize().
|
inlinenoexcept |
Sets a custom callback function to be triggered each time before updating the toplevel position or size.
callback | The callback function to be executed before updating the toplevel window or nullptr to disable. |
|
inlinenoexcept |
Retrieves the LToplevelRole associated with this session.
|
inlinenoexcept |
Retrieves the triggering event provided during the start of the session.
|
inlinenoexcept |
Checks if the session is currently active.
true
if the session is active, false
otherwise.