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

Manages session lock requests and state changes. More...

+ Inheritance diagram for LSessionLockManager:

Public Types

enum  State
 Represents the state of the session. More...
 
- Public Types inherited from LFactoryObject
enum class  Type : Int32
 Base factory object types. More...
 

Public Member Functions

 LSessionLockManager (const void *params) noexcept
 LSessionLockManager class constructor. More...
 
 ~LSessionLockManager ()
 Destructor of the LSessionLockManager class. More...
 
LClientclient () const noexcept
 Gets the client locking the session. More...
 
const std::vector< LSessionLockRole * > & roles () const noexcept
 Gets the Session Lock Surface Roles. More...
 
State state () const noexcept
 Gets the current state of the session. More...
 
void forceUnlock ()
 Forces the session to unlock. More...
 
virtual bool lockRequest (LClient *client)
 Handles a lock request from a client. More...
 
virtual void stateChanged ()
 Notifies a change in the session state. 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...
 

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

Manages session lock requests and state changes.

Clients using the Session Lock protocol can request the compositor to lock the user session and display arbitrary graphics (see LSessionLockRole) such as an authentication form to allow the user to unlock the session.
This class allows you to accept/decline such requests (see lockRequest()) and monitor changes in the session state (stateChanged()).

Member Enumeration Documentation

◆ State

enum State

Represents the state of the session.

Enumerator
Unlocked 

The session is unlocked.

Locked 

The session is locked.

DeadLocked 

The session is locked, but the locking client died.

Constructor & Destructor Documentation

◆ LSessionLockManager()

LSessionLockManager ( const void *  params)
noexcept

LSessionLockManager class constructor.

There is only one instance of LSessionLockManager, which can be accessed from LCompositor::sessionLockManager().

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

◆ ~LSessionLockManager()

~LSessionLockManager ( )
inline

Destructor of the LSessionLockManager class.

Invoked after LCompositor::onAnticipatedObjectDestruction().

Member Function Documentation

◆ client()

LClient * client ( ) const
noexcept

Gets the client locking the session.

Returns
A pointer to the client locking the session, or nullptr if the session is unlocked or the locking client died.

◆ roles()

const std::vector< LSessionLockRole * > & roles ( ) const
noexcept

Gets the Session Lock Surface Roles.

The client creates one for each output.

◆ state()

State state ( ) const
inlinenoexcept

Gets the current state of the session.

◆ forceUnlock()

void forceUnlock ( )

Forces the session to unlock.

If the locking client dies without unlocking the session, the session remains locked (DeadLocked state). This method allows the compositor to forcibly unlock the session, ideally after a fallback user authentication mechanism.

◆ lockRequest()

virtual bool lockRequest ( LClient client)
virtual

Handles a lock request from a client.

This method determines whether to grant permission for the client to lock the session. Returning true indicates permission, while false denies the request.

Warning
It's recommended that the client be a trusted and well-known entity.

This method is only invoked when the session state is Unlocked or DeadLocked. Louvre automatically ignores requests in the Locked state.

Parameters
clientThe client requesting to lock the session.

Default Implementation

{
L_UNUSED(client);
/* Allow all requests by default. */
return true;
}
LClient * client() const noexcept
Gets the client locking the session.
Definition: LSessionLockManager.cpp:24
virtual bool lockRequest(LClient *client)
Handles a lock request from a client.

◆ stateChanged()

virtual void stateChanged ( )
virtual

Notifies a change in the session state.

Default Implementation

{
switch (state())
{
case Unlocked:
break;
case Locked:
seat()->dnd()->cancel();
seat()->touch()->sendCancelEvent(LTouchCancelEvent());
seat()->keyboard()->setGrab(nullptr);
if (cursor()->output() && cursor()->output()->sessionLockRole())
{
seat()->pointer()->setFocus(cursor()->output()->sessionLockRole()->surface());
seat()->keyboard()->setFocus(cursor()->output()->sessionLockRole()->surface());
}
else
{
seat()->pointer()->setFocus(nullptr);
seat()->keyboard()->setFocus(nullptr);
}
break;
case DeadLocked:
break;
}
}
void cancel() noexcept
Cancels the session.
Definition: LDND.cpp:144
void setGrab(LSurface *surface)
Sets a keyboard grab.
Definition: LKeyboard.cpp:74
void setFocus(LSurface *surface)
Set keyboard focus.
Definition: LKeyboard.cpp:276
void setFocus(LSurface *surface, const LPoint &localPos) noexcept
Sets the pointer focus.
Definition: LPointer.cpp:47
void setDraggingSurface(LSurface *surface) noexcept
Keep track of the surface pressed by the main pointer button.
Definition: LPointer.cpp:339
LDND * dnd() const noexcept
Access to the drag & drop session manager.
Definition: LSeat.h:197
LKeyboard * keyboard() const noexcept
Access to keyboard events.
Definition: LSeat.h:179
LPointer * pointer() const noexcept
Access to pointer events.
Definition: LSeat.h:169
LTouch * touch() const noexcept
Access to touch events.
Definition: LSeat.h:189
State state() const noexcept
Gets the current state of the session.
Definition: LSessionLockManager.h:65
@ Locked
Definition: LSessionLockManager.h:28
@ DeadLocked
Definition: LSessionLockManager.h:29
@ Unlocked
Definition: LSessionLockManager.h:27
virtual void stateChanged()
Notifies a change in the session state.
void sendCancelEvent(const LTouchCancelEvent &event) noexcept
Send a cancel event to clients with surfaces assigned to touchpoints.
Definition: LTouch.cpp:123
LCursor * cursor() noexcept
Gets the compositor's cursor.
Definition: LCompositor.cpp:47
LSeat * seat() noexcept
Gets the compositor's seat.
Definition: LCompositor.cpp:42