Louvre
v2.13.0-1
C++ library for Wayland compositors
|
Louvre's core and objects factory. More...
Public Types | |
enum | CompositorState |
Compositor state. More... | |
Public Member Functions | |
LCompositor () noexcept | |
Constructor of the LCompositor class. More... | |
virtual | ~LCompositor () |
Destructor of the LCompositor class. More... | |
CompositorState | state () const noexcept |
Gets the current compositor state. More... | |
bool | start () |
Starts the main event loop and backends. More... | |
Int32 | processLoop (Int32 msTimeout) |
Process the compositor's main event loop. More... | |
Int32 | fd () const noexcept |
Gets a pollable file descriptor of the main event loop. More... | |
void | finish () noexcept |
Uninitializes the compositor. More... | |
LCursor * | cursor () const noexcept |
Gets the compositor cursor. More... | |
LSeat * | seat () const noexcept |
Gets the compositor seat. More... | |
LSessionLockManager * | sessionLockManager () const noexcept |
Provides access to the session lock manager. More... | |
LActivationTokenManager * | activationTokenManager () const noexcept |
Provides access to the activation token manager. More... | |
const std::list< LSurface * > & | surfaces () const noexcept |
Gets a list of all surfaces created by clients. More... | |
const std::list< LSurface * > & | layer (LSurfaceLayer layer) const noexcept |
Retrieves the list of surfaces within a specific layer. More... | |
const std::vector< LClient * > & | clients () const noexcept |
Gets a list of clients connected to the compositor. More... | |
LClient * | getClientFromNativeResource (const wl_client *client) noexcept |
Gets the LClient of a native Wayland wl_client resource. More... | |
const std::vector< LOutput * > & | outputs () const noexcept |
Gets a vector of all initialized outputs. More... | |
bool | addOutput (LOutput *output) |
Initializes the specified output. More... | |
void | removeOutput (LOutput *output) |
Uninitializes the specified output. More... | |
void | repaintAllOutputs () noexcept |
Unlocks the rendering thread of all initialized outputs. More... | |
LOutput * | mostIntersectedOutput (const LRect &rect, bool initializedOnly=true) const noexcept |
Searches for the most intersected output. More... | |
std::thread::id | mainThreadId () const noexcept |
Identifier of the main thread. More... | |
const std::filesystem::path & | defaultAssetsPath () const noexcept |
Gets the absolute path to the default Louvre assets directory. More... | |
const std::filesystem::path & | defaultBackendsPath () const noexcept |
Gets the absolute path to the default Louvre backends directory. More... | |
bool | loadGraphicBackend (const std::filesystem::path &path) noexcept |
Loads a graphic backend (dynamic library). More... | |
bool | isGraphicBackendInitialized () const noexcept |
Checks if the graphic backend is initialized. More... | |
const std::string & | defaultGraphicBackendName () const noexcept |
Gets the name of the default graphic backend. More... | |
void * | graphicBackendContextHandle () const noexcept |
Handle to the native context used by the graphic backend. More... | |
UInt32 | graphicBackendId () const noexcept |
Gets the ID of the current graphic backend. More... | |
bool | loadInputBackend (const std::filesystem::path &path) noexcept |
Loads an input backend (dynamic library). More... | |
bool | isInputBackendInitialized () const noexcept |
Checks if the input backend is initialized. More... | |
const std::string & | defaultInputBackendName () const noexcept |
Gets the name of the default input backend. More... | |
void * | inputBackendContextHandle () const noexcept |
Handle to the native context used by the input backend. More... | |
UInt32 | inputBackendId () const noexcept |
Gets the ID of the current input backend. More... | |
template<class Global > | |
LGlobal * | createGlobal (void *data=nullptr) noexcept |
Creates and adds a global to the compositor. More... | |
void | removeGlobal (LGlobal *global) noexcept |
Safely removes a global. More... | |
Static Public Member Functions | |
static const LVersion & | version () noexcept |
Gets the current Louvre version. More... | |
static wl_display * | display () noexcept |
Gets the native wl_display used by the compositor. More... | |
static wl_event_source * | addFdListener (int fd, void *userData, int(*callback)(int, unsigned int, void *), UInt32 flags=WL_EVENT_READABLE) |
Adds a pollable file descriptor listener to the main event loop. More... | |
static void | removeFdListener (wl_event_source *source) |
Removes a previously added file descriptor from the compositor's event loop. More... | |
static void | flushClients () noexcept |
Flush all pending client events. More... | |
static EGLDisplay | eglDisplay () noexcept |
Gets the main EGL display created by the graphic backend. More... | |
static EGLContext | eglContext () noexcept |
Gets the main EGL context created by the graphic backend. More... | |
Virtual Methods | |
virtual void | initialized () |
Notifies a successful compositor initialization. More... | |
virtual void | uninitialized () |
Notifies the uninitialization of the compositor. More... | |
virtual LFactoryObject * | createObjectRequest (LFactoryObject::Type objectType, const void *params) |
Request to create a specific LFactoryObject. More... | |
virtual void | onAnticipatedObjectDestruction (LFactoryObject *object) |
Announce the anticipated destruction of an LFactoryObject. More... | |
virtual bool | createGlobalsRequest () |
Wayland globals initialization. More... | |
virtual bool | globalsFilter (LClient *client, LGlobal *global) |
Globals filter. More... | |
Louvre's core and objects factory.
The LCompositor class manages the main event loop, backend systems, and provides virtual constructors and destructors for Louvre objects with interfaces you can override.
enum CompositorState |
Compositor state.
|
noexcept |
Constructor of the LCompositor class.
|
virtualdefault |
Destructor of the LCompositor class.
|
noexcept |
Gets the current compositor state.
bool start | ( | ) |
Starts the main event loop and backends.
After successful initialization, notified with the initialized() event, the compositor can receive connections from Wayland clients and initialize output rendering threads using the addOutput() method.
false
on failure and true
otherwise. Process the compositor's main event loop.
msTimeout | Milliseconds to wait before an event occurs. Setting it to 0 disables the timeout, and setting it to -1 makes it wait indefinitely until an event occurs. |
|
noexcept |
Gets a pollable file descriptor of the main event loop.
|
noexcept |
Uninitializes the compositor.
|
staticnoexcept |
Gets the native wl_display
used by the compositor.
wl_display
.
|
static |
Adds a pollable file descriptor listener to the main event loop.
fd | The file descriptor to be added. |
userData | User data to pass to the callback function. |
callback | The callback function to handle events on the file descriptor. |
flags | Flags to specify the type of event to listen for (e.g., WL_EVENT_READABLE). |
|
static |
Removes a previously added file descriptor from the compositor's event loop.
source | The wl_event_source to remove. |
|
noexcept |
Gets the compositor cursor.
This method must be accessed within or after the initialized() or cursorInitialized() events. If the cursor has not yet been initialized, this method returns nullptr
.
nullptr
if not yet initialized.
|
noexcept |
|
noexcept |
Provides access to the session lock manager.
The session lock manager allows you to handle client requests to lock the user session and display arbitrary content.
|
noexcept |
Provides access to the activation token manager.
The activation token manager allows you to handle client requests to activate surfaces of other clients.
|
noexcept |
|
noexcept |
Retrieves the list of surfaces within a specific layer.
layer | The layer index to retrieve. See LSurfaceLayer. |
|
noexcept |
Gets a list of clients connected to the compositor.
This method returns a list of clients that are currently connected to the compositor.
|
staticnoexcept |
Flush all pending client events.
This method immediatly flushes all pending client events.
|
noexcept |
|
noexcept |
Gets a vector of all initialized outputs.
This method returns a vector of all outputs that have been initialized using the addOutput() method.
bool addOutput | ( | LOutput * | output | ) |
Initializes the specified output.
This method creates a new rendering thread and initializes the specified output. Once initialized, the LOutput::initializeGL() event is triggered, and LOutput::repaint() can be used to unlock the rendering thread loop, which triggers LOutput::paintGL() events.
This adds the output to the outputs() vector.
output | The output to initialize, obtained from LSeat::outputs(). |
true
on success, false
on failure. void removeOutput | ( | LOutput * | output | ) |
Uninitializes the specified output.
This method uninitializes and removes the specified output from the compositor, stopping its thread, rendering loop and triggering the LOutput::uninitializeGL() event.
...GL()
events) has no effect. Doing so would lead to a deadlock, so Louvre simply ignores the request.output | The output to remove, previously added to the compositor. See outputs(). |
|
noexcept |
Unlocks the rendering thread of all initialized outputs.
This method schedules a new rendering frame by calling the LOutput::repaint() method to all initialized outputs.
Searches for the most intersected output.
Checks which output within the global compositor space intersects the given rectangle the most.
rect | The rectangle to check in compositor-global coordinates. |
initializedOnly | If true , only considers initialized outputs. Default is true . |
nullptr
if no output is found.
|
noexcept |
Identifier of the main thread.
This ID corresponds to the primary thread responsible for managing the Wayland and input backend event loops, while individual output operations are performed on separate threads.
|
staticnoexcept |
Gets the main EGL display created by the graphic backend.
|
staticnoexcept |
Gets the main EGL context created by the graphic backend.
|
noexcept |
|
noexcept |
|
noexcept |
Loads a graphic backend (dynamic library).
Use this method to load a custom graphic backend before calling start().
By default, Louvre tries to load the Wayland backend if WAYLAND_DISPLAY is set, and then the DRM backend if fails.
path | Absolute path of the dynamic library. |
true
if the backend is successfully loaded, false
otherwise.
|
noexcept |
Checks if the graphic backend is initialized.
Use this method to determine whether the graphic backend has been initialized after calling start().
true
if the graphic backend is initialized, false
otherwise.
|
noexcept |
Gets the name of the default graphic backend.
This name is used when the LOUVRE_GRAPHIC_BACKEND environment variable is unset.
It is automatically generated by Meson and defaults to drm
.
|
noexcept |
Handle to the native context used by the graphic backend.
This opaque handle is unique to each graphic backend.
You can use this handle to configure specific aspects of each backend.
|
noexcept |
Gets the ID of the current graphic backend.
Each graphic backend is assigned a unique UInt32 ID. You can use this method to retrieve the ID of the current graphic backend in use.
The IDs of graphic backends shipped with Louvre are listed in the LGraphicBackendID enum.
|
noexcept |
Loads an input backend (dynamic library).
Use this method to load a custom graphic backend before calling start().
By default, Louvre tries to load the Wayland backend if WAYLAND_DISPLAY is set, and then the Libinput backend if fails.
path | Location of the backend's dynamic library. |
true
if the backend is successfully loaded, false
otherwise.
|
noexcept |
Checks if the input backend is initialized.
Use this method to determine whether the input backend has been initialized after calling start().
true
if the input backend is initialized, false
otherwise.
|
noexcept |
Gets the name of the default input backend.
This name is used when the LOUVRE_INPUT_BACKEND environment variable is unset.
It is automatically generated by Meson and defaults to libinput
.
|
noexcept |
Handle to the native context used by the input backend.
This opaque handle is unique to each input backend.
You can use this handle to configure specific aspects of each backend.
|
noexcept |
Gets the ID of the current input backend.
Each input backend is assigned a unique Louvre::UInt32 ID. You can use this method to retrieve the ID of the current input backend in use.
The IDs of input backends shipped with Louvre are listed in the Louvre::LInputBackendID enum.
|
inlinenoexcept |
Creates and adds a global to the compositor.
This method creates and adds a global to the compositor. Globals implemented by Louvre can be found in <protocols/{protocol}/G{global}.h>
.
Louvre automatically creates all the supported globals during compositor initialization. See LCompositor::createGlobalsRequest().
Global | The type of global to create. It should be a subclass of Louvre::LResource. |
|
noexcept |
Safely removes a global.
This method performs a lazy removal of an LGlobal created with createGlobal(), ensuring clients are notified before it is destroyed.
global | Pointer to the LGlobal instance to remove. |
|
virtual |
Notifies a successful compositor initialization.
Use this event to handle the successful initialization of the compositor after calling start().
Here you should perform initial configuration tasks, such as setting up outputs, as demonstrated in the default implementation.
|
virtual |
Notifies the uninitialization of the compositor.
This event is triggered right before the compositor is uninitialized when finish() is called. At this point, both the input and graphic backends, along with other resources such as connected clients and initialized outputs, are still operational.
Use this opportunity to release any compositor-specific resources that you may have created.
|
virtual |
Request to create a specific LFactoryObject.
Certain classes in Louvre have an interface that can be overridden.
Instances of these classes can only be created from this virtual constructor when requested by the compositor.
Refer to LFactoryObject::Type to see all the classes that can be overridden.
objectType | Indicates the type of the class instance to return. |
params | An opaque data type that should be passed to the object's constructor. |
nullptr
is returned, Louvre will create an instance of the object using the base class.
|
virtual |
Announce the anticipated destruction of an LFactoryObject.
When an LFactoryObject destructor is invoked, it is likely that associated resources are no longer available.
Using this event, however, provides an opportunity to access those resources.
object | The object for which destruction is anticipated. |
|
virtual |
Wayland globals initialization.
Override this method if you want to remove or add custom Wayland globals.
true
on success, false
on failure (prevents the compositor from starting).Globals filter.
Filter to prevent clients from using specific protocol globals.
It is recommended to use this method to allow only well-known clients to bind to protocols such as Session Lock, Wlr Screen Copy, and others.
See LClient::credentials() and LGlobal::isType().
client | The client attempting to bind to the global. |
global | The protocol global the client is attempting to bind to. |
true
to allow the client, false
to deny it.The default implementation allows all clients to bind to all globals.