![]() |
Louvre
v2.9.0-1
C++ library for Wayland compositors
|
Toplevel move session utility. More...
Public Types | |
using | OnBeforeUpdateCallback = std::function< void(LToplevelMoveSession *)> |
Callback function type used in setOnBeforeUpdateCallback() More... | |
Public Member Functions | |
bool | start (const LEvent &triggeringEvent, const LPoint &initDragPoint) |
Start the move session. More... | |
void | updateDragPoint (const LPoint &pos) |
Updates the drag point, causing the toplevel to move. More... | |
const std::vector< LToplevelMoveSession * >::const_iterator | stop () |
Stops the move 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 | setOnBeforeUpdateCallback (const OnBeforeUpdateCallback &callback) noexcept |
Sets a custom callback function to be triggered each time before updating the toplevel position. 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 move session utility.
This class serves as a utility for handling interactive move sessions for LToplevelRole surfaces.
Each LToplevelRole has an associated move session instance LToplevelRole::moveSession().
When a client triggers LToplevelRole::startMoveRequest(), the start() method should be invoked, providing the triggering event 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::toplevelMoveSessions() vector.
Subsequently, whenever the drag point changes, such as within an LPointer::pointerMoveEvent() or LTouch::touchMoveEvent(), updateDragPoint() should be called. The LSeat::toplevelMoveSessions() provides access to all active move 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 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::toplevelMoveSessions() 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(LToplevelMoveSession*)> |
Callback function type used in setOnBeforeUpdateCallback()
Start the move session.
triggeringEvent | The triggering event provided in LToplevelRole::startMoveRequest(). |
initDragPoint | The initial pointer, touch, or other position at the start of the move 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.
pos | The new position of the pointer or touch point. |
const std::vector< LToplevelMoveSession * >::const_iterator stop | ( | ) |
Stops the move session.
This method ends the current move 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 custom callback function to be triggered each time before updating the toplevel position.
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.