Louvre
v2.13.0-1
C++ library for Wayland compositors
|
Activation Token Manager. More...
Public Member Functions | |
LActivationTokenManager (const void *params) noexcept | |
LActivationTokenManager class constructor. More... | |
~LActivationTokenManager () noexcept | |
Destructor of the LActivationTokenManager class. More... | |
const std::unordered_map< std::string, LActivationToken * > & | tokens () const noexcept |
Retrieve available tokens. More... | |
LActivationToken * | token () const noexcept |
Retrieve the current token. More... | |
void | destroyTokensOlderThanMs (UInt32 ms) |
Destroy tokens older than the specified number of milliseconds. 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... | |
LObject & | operator= (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 void | createTokenRequest () |
Request to create an activation token. More... | |
virtual void | activateSurfaceRequest (LSurface *surface) |
Request to activate a surface. More... | |
Additional Inherited Members | |
Public Types inherited from LFactoryObject | |
enum class | Type : Int32 |
Base factory object types. 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... | |
Activation Token Manager.
The XDG Activation protocol allows clients to pass focus to another client's surface.
The protocol functions as follows:
The default implementations of createTokenRequest() and activateSurfaceRequest() only accept requests that provide a valid triggering event and destroy the token after it is used, as well as those that haven't been used in the last 10 seconds. This is for security reasons, tokens can remain valid indefinitely if desired.
There is a unique instance of this class, created within LCompositor::createObjectRequest(), which can be accessed globally via Louvre::activationTokenManager().
To disable this protocol, remove its global from LCompositor::createGlobalsRequest()
|
noexcept |
LActivationTokenManager class constructor.
There is only one instance of this class, which can be accessed globally via activationTokenManager().
params | Internal parameters provided in LCompositor::createObjectRequest(). |
|
noexcept |
Destructor of the LActivationTokenManager class.
Invoked after LCompositor::onAnticipatedObjectDestruction().
|
inlinenoexcept |
Retrieve available tokens.
Provides all currently available tokens, which clients can use to activate surfaces.
To expire tokens, use LActivationToken::destroy() or the destroyTokensOlderThanMs() method.
|
inlinenoexcept |
Retrieve the current token.
This method provides access to the token used during createTokenRequest() or activateSurfaceRequest() requests. If neither request is in progress, this method returns nullptr
.
The token is not provided as an argument to those requests because the default implementation of activateSurfaceRequest() triggers LToplevelRole::activateRequest() if the surface has a toplevel role. This way, the token can be accessed from LToplevelRole::activateRequest() if needed.
void destroyTokensOlderThanMs | ( | UInt32 | ms | ) |
Destroy tokens older than the specified number of milliseconds.
The default implementation of activateSurfaceRequest() uses this method to destroy all tokens older than 10 seconds to prevent unnecessary tokens from remaining active.
|
virtual |
Request to create an activation token.
This request is triggered each time a client wants to create a new activation token. The activation token data can be accessed via token(). If the token is denied, token()->destroy()
must be called, otherwise, the token will be retained in the tokens() map, and clients will be allowed to use it for activateSurfaceRequest().
The default implementation only accepts tokens generated by the currently focused client.
|
virtual |
Request to activate a surface.
This request indicates that a client wants to activate one of its surfaces and is only triggered if the client provides one of the tokens(), which can be accessed during the request with token().
The default implementation verifies if the token is recent and destroys it immediately after use, along with any tokens older than 10 seconds.
If the token is not destroyed, LActivationToken::timesUsed() is incremented by 1.
surface | The surface to activate. |