Louvre  v1.2.1-2
C++ library for Wayland compositors
List of all members | Public Types | Public Member Functions | Static Public Member Functions
LCompositor Class Reference

#include <LCompositor.h>

Louvre's primary class and resource factory. More...

Detailed Description

Louvre's primary class and resource factory.

The LCompositor class initializes Louvre's Wayland event loop and backend systems.
After calling start(), the initialized() virtual method is invoked to indicate successful initialization. Any initial setup should be done there or later to prevent issues.

LCompositor also follows the factory design pattern, using virtual methods as constructors and destructors for various library classes. Each of those classes has multiple virtual methods that handle events. To customize a class's behavior for a specific event, subclass it and override the corresponding virtual method. To make the library use your custom subclass, override its virtual constructor in LCompositor.

For example, consider the LOutput class, created within LCompositor::createOutputRequest(). To use your custom LOutput subclass, override LCompositor::createOutputRequest() and return an instance of your subclass. This way, the library will use your custom LOutput subclass for output-related events.

Public Types

enum  CompositorState
 Possible compositor states. More...
 

Public Member Functions

 LCompositor ()
 Constructor of the LCompositor class. More...
 
virtual ~LCompositor ()
 Destructor of the LCompositor class. More...
 
virtual bool createGlobalsRequest ()
 Wayland globals initialization. More...
 
const std::filesystem::path & defaultAssetsPath () const
 Get the absolute path to the default Louvre assets directory. More...
 
const std::filesystem::path & defaultBackendsPath () const
 Get the absolute path to the default Louvre backends directory. More...
 
bool loadGraphicBackend (const std::filesystem::path &path)
 Loads a graphic backend (dynamic library). More...
 
bool isGraphicBackendInitialized () const
 Checks if the graphic backend is initialized. More...
 
const std::string & defaultGraphicBackendName () const
 Get the name of the default graphic backend. More...
 
bool loadInputBackend (const std::filesystem::path &path)
 Loads an input backend (dynamic library). More...
 
bool isInputBackendInitialized () const
 Checks if the input backend is initialized. More...
 
const std::string & defaultInputBackendName () const
 Get the name of the default input backend. More...
 
virtual void initialized ()
 Notifies a successful compositor initialization. More...
 
virtual void uninitialized ()
 Notifies the uninitialization of the compositor. More...
 
virtual void cursorInitialized ()
 Notifies a successful cursor initialization. More...
 
CompositorState state () const
 Gets the current compositor state. More...
 
bool start ()
 Starts the event loop and backends. More...
 
Int32 processLoop (Int32 msTimeout)
 Process the compositor's main event loop. More...
 
Int32 fd () const
 Get a pollable file descriptor of the main event loop. More...
 
void finish ()
 Ends and uninitializes the compositor. More...
 
LCursorcursor () const
 Gets the compositor cursor. More...
 
LSeatseat () const
 Gets the compositor seat. More...
 
void repaintAllOutputs ()
 Schedule a new rendering frame for each output in the compositor. More...
 
bool addOutput (LOutput *output)
 Initializes the specified output. More...
 
void removeOutput (LOutput *output)
 Uninitializes the specified output. More...
 
const std::list< LSurface * > & surfaces () const
 Get a list of all surfaces created by clients. More...
 
const std::vector< LOutput * > & outputs () const
 Get a list of all initialized outputs. More...
 
const std::vector< LClient * > & clients () const
 Get a list of clients connected to the compositor. More...
 
LClientgetClientFromNativeResource (wl_client *client)
 Gets the LClient of a native Wayland wl_client resource. More...
 
std::thread::id mainThreadId () const
 Identifier of the main thread. More...
 
Virtual Constructors

Virtual constructors are used to dynamically instantiate variants of a base or abstract class.

The compositor uses virtual constructors to create and keep track of resources like LSurface, LOutput, LKeyboard, etc, and for letting you use your own subclasses and override their virtual methods.

virtual LOutputcreateOutputRequest (const void *params)
 Virtual constructor for creating LOutput instances when needed by the graphic backend. More...
 
virtual LClientcreateClientRequest (const void *params)
 Virtual constructor for creating LClient instances when a new client connects. More...
 
virtual LSurfacecreateSurfaceRequest (const void *params)
 Virtual constructor for creating LSurface instances when a client creates a new surface. More...
 
virtual LSeatcreateSeatRequest (const void *params)
 Virtual constructor for creating the LSeat instance during compositor initialization. More...
 
virtual LPointercreatePointerRequest (const void *params)
 Virtual constructor for creating the LPointer instance during LSeat initialization. More...
 
virtual LKeyboardcreateKeyboardRequest (const void *params)
 Virtual constructor for creating the LKeyboard instance during LSeat initialization. More...
 
virtual LDNDManagercreateDNDManagerRequest (const void *params)
 Virtual constructor for creating the LDNDManager instance during LSeat initialization. More...
 
virtual LToplevelRolecreateToplevelRoleRequest (const void *params)
 Virtual constructor for creating LToplevelRole instances when a client creates a toplevel role for a surface. More...
 
virtual LPopupRolecreatePopupRoleRequest (const void *params)
 Virtual constructor for creating LPopupRole instances when a client creates a Popup role for a surface. More...
 
virtual LSubsurfaceRolecreateSubsurfaceRoleRequest (const void *params)
 Virtual constructor for creating LSubsurfaceRole instances when a client creates a Subsurface role for a surface. More...
 
virtual LCursorRolecreateCursorRoleRequest (const void *params)
 Virtual constructor for creating LCursorRole instances when a client wants to use a surface as a cursor. More...
 
virtual LDNDIconRolecreateDNDIconRoleRequest (const void *params)
 Virtual constructor for creating LDNDIconRole instances when a client wants to use a surface as an icon for a Drag & Drop session. More...
 
Virtual Destructors

Virtual destructors are used by the compositor to provide early notification of the destruction of a resource.

Warning
The compositor automatically handles the destruction of the resource provided as an argument. Therefore, you should not call delete.
virtual void destroyOutputRequest (LOutput *output)
 Virtual destructor for the LOutput class. More...
 
virtual void destroyClientRequest (LClient *client)
 Virtual destructor for the LClient class. More...
 
virtual void destroySurfaceRequest (LSurface *surface)
 Virtual destructor for the LSurface class. More...
 
virtual void destroySeatRequest (LSeat *seat)
 Virtual destructor for the LSeat class. More...
 
virtual void destroyPointerRequest (LPointer *pointer)
 Virtual destructor for the LPointer class. More...
 
virtual void destroyKeyboardRequest (LKeyboard *keyboard)
 Virtual destructor for the LKeyboard class. More...
 
virtual void destroyDNDManagerRequest (LDNDManager *dndManager)
 Virtual destructor for the LDNDManager class. More...
 
virtual void destroyToplevelRoleRequest (LToplevelRole *toplevel)
 Virtual destructor for the LToplevelRole class. More...
 
virtual void destroyPopupRoleRequest (LPopupRole *popup)
 Virtual destructor for the LPopupRole class. More...
 
virtual void destroySubsurfaceRoleRequest (LSubsurfaceRole *subsurface)
 Virtual destructor for the LSubsurfaceRole class. More...
 
virtual void destroyCursorRoleRequest (LCursorRole *cursor)
 Virtual destructor for the LCursorRole class. More...
 
virtual void destroyDNDIconRoleRequest (LDNDIconRole *icon)
 Virtual destructor for the LDNDIconRole class. More...
 

Static Public Member Functions

static LCompositorcompositor ()
 Get the static LCompositor instance. More...
 
static const LVersionversion ()
 Get the current Louvre version. More...
 
static wl_display * display ()
 Get the native wl_display used by the compositor. More...
 
static wl_event_loop * eventLoop ()
 Get the main wl_event_loop 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)
 Add a pollable file descriptor to the compositor's event loop. More...
 
static void removeFdListener (wl_event_source *source)
 Removes a previously added file descriptor from the compositor's event loop. More...
 
static UInt32 nextSerial ()
 Get a new positive integer number, incrementally. More...
 
static EGLDisplay eglDisplay ()
 Get the main EGL display created by the graphic backend. More...
 
static EGLContext eglContext ()
 Get the main EGL context created by the graphic backend. More...
 
static void flushClients ()
 Flush all pending client events. More...
 

Member Enumeration Documentation

◆ CompositorState

Possible compositor states.

Enumerator
Uninitialized 

Uninitialized.

Initializing 

Changing from uninitialized to initialized.

Initialized 

Initialized.

Uninitializing 

Changing from any state to uninitialized.

Pausing 

Changing from initialized to paused.

Paused 

Idle state during a session (TTY) switch.

Resuming 

Changing from paused to initialized.

Constructor & Destructor Documentation

◆ LCompositor()

Constructor of the LCompositor class.

◆ ~LCompositor()

~LCompositor ( )
virtualdefault

Destructor of the LCompositor class.

Member Function Documentation

◆ compositor()

LCompositor * compositor ( )
static

Get the static LCompositor instance.

This method provides access to the single LCompositor instance that can exist per process.
You can also access it from any Louvre object with object->compositor().

Returns
A pointer to the LCompositor instance.

◆ version()

const LVersion & version ( )
static

Get the current Louvre version.

◆ createGlobalsRequest()

virtual bool createGlobalsRequest ( )
virtual

Wayland globals initialization.

Override this method if you want to remove or add custom Wayland globals when initializing the compositor.

Returns
true on success, false on failure (prevents the compositor from starting).
Default Implementation
{
wl_global_create(display(), &wl_compositor_interface,
LOUVRE_WL_COMPOSITOR_VERSION, this, &GCompositor::GCompositorPrivate::bind);
wl_global_create(display(), &wl_seat_interface,
LOUVRE_WL_SEAT_VERSION, this, &GSeat::GSeatPrivate::bind);
wl_global_create(display(), &wl_subcompositor_interface,
LOUVRE_WL_SUBCOMPOSITOR_VERSION, this, &GSubcompositor::GSubcompositorPrivate::bind);
wl_global_create(display(), &wl_data_device_manager_interface,
LOUVRE_WL_DATA_DEVICE_MANAGER_VERSION, this, &GDataDeviceManager::GDataDeviceManagerPrivate::bind);
wl_global_create(display(), &xdg_wm_base_interface,
LOUVRE_XDG_WM_BASE_VERSION, this, &Protocols::XdgShell::GXdgWmBase::GXdgWmBasePrivate::bind);
wl_global_create(display(), &zxdg_decoration_manager_v1_interface,
LOUVRE_XDG_DECORATION_MANAGER_VERSION, this, &Protocols::XdgDecoration::GXdgDecorationManager::GXdgDecorationManagerPrivate::bind);
wl_global_create(display(), &zwp_linux_dmabuf_v1_interface,
LOUVRE_LINUX_DMA_BUF_VERSION, this, &Protocols::LinuxDMABuf::GLinuxDMABuf::GLinuxDMABufPrivate::bind);
wl_global_create(display(), &wp_presentation_interface,
LOUVRE_WP_PRESENTATION_VERSION, this, &Protocols::WpPresentationTime::GWpPresentation::GWpPresentationPrivate::bind);
wl_global_create(display(), &wp_viewporter_interface,
LOUVRE_VIEWPORTER_VERSION, this, &Protocols::Viewporter::GViewporter::GViewporterPrivate::bind);
wl_global_create(display(), &wp_fractional_scale_manager_v1_interface,
LOUVRE_FRACTIONAL_SCALE_VERSION, this, &Protocols::FractionalScale::GFractionalScaleManager::GFractionalScaleManagerPrivate::bind);
wl_global_create(display(), &zwlr_gamma_control_manager_v1_interface,
LOUVRE_GAMMA_CONTROL_MANAGER_VERSION, this, &Protocols::GammaControl::GGammaControlManager::GGammaControlManagerPrivate::bind);
wl_global_create(display(), &wp_tearing_control_manager_v1_interface,
LOUVRE_TEARING_CONTROL_MANAGER_VERSION, this, &Protocols::TearingControl::GTearingControlManager::GTearingControlManagerPrivate::bind);
wl_display_init_shm(display());
return true;
}
virtual bool createGlobalsRequest()
Wayland globals initialization.
static wl_display * display()
Get the native wl_display used by the compositor.
Definition: LCompositor.cpp:345

◆ defaultAssetsPath()

const std::filesystem::path & defaultAssetsPath ( ) const

Get the absolute path to the default Louvre assets directory.

This path is automatically generated by Meson and typically points to PREFIX/DATADIR/Louvre/assets.

Returns
The absolute path to the default Louvre assets directory.

◆ defaultBackendsPath()

const std::filesystem::path & defaultBackendsPath ( ) const

Get the absolute path to the default Louvre backends directory.

This path is automatically generated by Meson and typically points to PREFIX/LIBDIR/Louvre/backends. Used when the LOUVRE_BACKENDS_PATH environment variable is unset.

Returns
The absolute path to the default Louvre backends directory.

◆ loadGraphicBackend()

bool loadGraphicBackend ( const std::filesystem::path &  path)

Loads a graphic backend (dynamic library).

Use this method to load a custom graphic backend before calling start(). By default, Louvre loads the DRM backend which is tipically located at /usr/local/lib/Louvre/backends/graphic/drm.so.

Note
Instead of using this method, a more preferable approach is to let the user choose the graphical backend by configuring the LOUVRE_BACKENDS_PATH and LOUVRE_GRAPHIC_BACKEND environment variables.
Parameters
pathAbsolute path of the dynamic library.
Returns
true if the backend is successfully loaded, false otherwise.

◆ isGraphicBackendInitialized()

bool isGraphicBackendInitialized ( ) const

Checks if the graphic backend is initialized.

Use this method to determine whether the graphic backend has been initialized after calling start().

Returns
true if the graphic backend is initialized, false otherwise.

◆ defaultGraphicBackendName()

const std::string & defaultGraphicBackendName ( ) const

Get 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.

Returns
The name of the default graphic backend.

◆ loadInputBackend()

bool loadInputBackend ( const std::filesystem::path &  path)

Loads an input backend (dynamic library).

Use this method to load a custom input backend before calling start(). By default, Louvre loads the Libinput backend which is tipically located at /usr/local/lib/Louvre/backends/input/libinput.so.

Note
Instead of using this method, a more preferable approach is to let the user choose the graphical backend by configuring the LOUVRE_BACKENDS_PATH and LOUVRE_INPUT_BACKEND environment variables.
Parameters
pathLocation of the backend's dynamic library.
Returns
true if the backend is successfully loaded, false otherwise.

◆ isInputBackendInitialized()

bool isInputBackendInitialized ( ) const

Checks if the input backend is initialized.

Use this method to determine whether the input backend has been initialized after calling start().

Returns
true if the input backend is initialized, false otherwise.

◆ defaultInputBackendName()

const std::string & defaultInputBackendName ( ) const

Get 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.

Returns
The name of the default input backend.

◆ initialized()

virtual void initialized ( )
virtual

Notifies a successful compositor initialization.

Use this event to handle the successful initialization of the compositor after calling the start() method. Here you should perform initial configuration tasks, such as setting up outputs, as demonstrated in the default implementation.

Default Implementation
{
// Set a keyboard map with "latam" layout
seat()->keyboard()->setKeymap(nullptr, nullptr, "latam", nullptr);
Int32 totalWidth = 0;
// Initialize and arrange outputs from left to right
for (LOutput *output : seat()->outputs())
{
// Set scale 2 to outputs with DPI >= 200
output->setScale(output->dpi() >= 200 ? 2.f : 1.f);
output->setTransform(LFramebuffer::Normal);
output->setPos(LPoint(totalWidth, 0));
totalWidth += output->size().w();
addOutput(output);
output->repaint();
}
}
bool addOutput(LOutput *output)
Initializes the specified output.
Definition: LCompositor.cpp:381
LSeat * seat() const
Gets the compositor seat.
Definition: LCompositor.cpp:370
virtual void initialized()
Notifies a successful compositor initialization.
const std::vector< LOutput * > & outputs() const
Get a list of all initialized outputs.
Definition: LCompositor.cpp:483
@ Normal
No transformation.
Definition: LFramebuffer.h:44
bool setKeymap(const char *rules=nullptr, const char *model=nullptr, const char *layout=nullptr, const char *variant=nullptr, const char *options=nullptr)
Set the keyboard map.
Definition: LKeyboard.cpp:83
LKeyboard * keyboard() const
Access to keyboard events.
Definition: LSeat.cpp:127
int32_t Int32
32 bits signed integer
Definition: LNamespaces.h:210
LPointTemplate< Int32, Float32 > LPoint
2D vector of 32 bits integers
Definition: LNamespaces.h:240

◆ uninitialized()

virtual void uninitialized ( )
virtual

Notifies the uninitialization of the compositor.

This event is called just 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.

Default Implementation
{
/* No default implementation */
}
virtual void uninitialized()
Notifies the uninitialization of the compositor.

◆ cursorInitialized()

virtual void cursorInitialized ( )
virtual

Notifies a successful cursor initialization.

Use this event to handle the successful initialization of the cursor. It is recommended to load cursor textures within this method. The LXCursor class provides the LXCursor::loadXCursorB() method for loading pixmaps of XCursors available on the system.

The default implementation includes a commented example demonstrating how to load XCursor pixmaps and assign them to the cursor.

Default Implementation
{
// Example to load an XCursor
/*
// Loads the "hand1" cursor
LXCursor *handCursor = LXCursor::loadXCursorB("hand1");
// Returns nullptr if not found
if (handCursor)
{
// Set as the cursor texture
cursor()->setTextureB(handCursor->texture(), handCursor->hotspotB());
}
*/
}
virtual void cursorInitialized()
Notifies a successful cursor initialization.

◆ state()

Gets the current compositor state.

Use this method to retrieve the current state of the compositor.

See also
LCompositor::CompositorState enum for possible state values.
Returns
The current compositor state.

◆ createOutputRequest()

virtual LOutput* createOutputRequest ( const void *  params)
virtual

Virtual constructor for creating LOutput instances when needed by the graphic backend.

This method is invoked by the graphic backend when it needs to create a new output.

Returns
An instance of LOutput or a subclass of LOutput.
Default Implementation
LOutput *LCompositor::createOutputRequest(const void *params)
{
return new LOutput(params);
}
virtual LOutput * createOutputRequest(const void *params)
Virtual constructor for creating LOutput instances when needed by the graphic backend.

◆ createClientRequest()

virtual LClient* createClientRequest ( const void *  params)
virtual

Virtual constructor for creating LClient instances when a new client connects.

This method is called when a new client establishes a connection with the compositor.

Parameters
paramsInternal Louvre parameters for creating the client.
Returns
An instance of LClient or a subclass of LClient.
Default Implementation
LClient *LCompositor::createClientRequest(const void *params)
{
return new LClient(params);
}
virtual LClient * createClientRequest(const void *params)
Virtual constructor for creating LClient instances when a new client connects.

◆ createSurfaceRequest()

virtual LSurface* createSurfaceRequest ( const void *  params)
virtual

Virtual constructor for creating LSurface instances when a client creates a new surface.

This method is called when a client creates a new surface.

Parameters
paramsInternal Louvre parameters for creating the surface.
Returns
An instance of LSurface or a subclass of LSurface.
Default Implementation
LSurface *LCompositor::createSurfaceRequest(const void *params)
{
return new LSurface(params);
}
virtual LSurface * createSurfaceRequest(const void *params)
Virtual constructor for creating LSurface instances when a client creates a new surface.

◆ createSeatRequest()

virtual LSeat* createSeatRequest ( const void *  params)
virtual

Virtual constructor for creating the LSeat instance during compositor initialization.

This method is called during the compositor initialization. The LSeat class provides virtual methods to access native events generated by the input backend, handle output hotplugging events, TTY switching events, and more.

Parameters
paramsInternal Louvre parameters for creating the seat.
Returns
An instance of LSeat or a subclass of LSeat.
Default Implementation
LSeat *LCompositor::createSeatRequest(const void *params)
{
return new LSeat(params);
}
virtual LSeat * createSeatRequest(const void *params)
Virtual constructor for creating the LSeat instance during compositor initialization.

◆ createPointerRequest()

virtual LPointer* createPointerRequest ( const void *  params)
virtual

Virtual constructor for creating the LPointer instance during LSeat initialization.

This method is called during LSeat initialization. The LPointer class provides virtual methods to listen to pointer events generated by the input backend.

Parameters
paramsInternal Louvre parameters for creating the pointer.
Returns
An instance of LPointer or a subclass of LPointer.
Default Implementation
LPointer *LCompositor::createPointerRequest(const void *params)
{
return new LPointer(params);
}
virtual LPointer * createPointerRequest(const void *params)
Virtual constructor for creating the LPointer instance during LSeat initialization.

◆ createKeyboardRequest()

virtual LKeyboard* createKeyboardRequest ( const void *  params)
virtual

Virtual constructor for creating the LKeyboard instance during LSeat initialization.

This method is called during LSeat initialization. The LKeyboard class provides virtual methods to listen to keyboard events generated by the input backend.

Parameters
paramsInternal Louvre parameters for creating the keyboard.
Returns
An instance of LKeyboard or a subclass of LKeyboard.
Default Implementation
LKeyboard *LCompositor::createKeyboardRequest(const void *params)
{
return new LKeyboard(params);
}
virtual LKeyboard * createKeyboardRequest(const void *params)
Virtual constructor for creating the LKeyboard instance during LSeat initialization.

◆ createDNDManagerRequest()

virtual LDNDManager* createDNDManagerRequest ( const void *  params)
virtual

Virtual constructor for creating the LDNDManager instance during LSeat initialization.

This method is called during LSeat initialization. The LDNDManager class provides virtual methods that notify the start and end of Drag & Drop sessions between clients.

Parameters
paramsInternal Louvre parameters for creating the DND manager.
Returns
An instance of LDNDManager or a subclass of LDNDManager.
Default Implementation
LDNDManager *LCompositor::createDNDManagerRequest(const void *params)
{
return new LDNDManager(params);
}
virtual LDNDManager * createDNDManagerRequest(const void *params)
Virtual constructor for creating the LDNDManager instance during LSeat initialization.

◆ createToplevelRoleRequest()

virtual LToplevelRole* createToplevelRoleRequest ( const void *  params)
virtual

Virtual constructor for creating LToplevelRole instances when a client creates a toplevel role for a surface.

This method is called when a client creates a toplevel role for a surface. The LToplevelRole class provides virtual methods to notify changes in geometry, state (activated, maximized, fullscreen, etc.), the start of interactive moving and resizing sessions, and more.

Parameters
paramsInternal Louvre parameters for creating the toplevel role.
Returns
An instance of LToplevelRole or a subclass of LToplevelRole.
Default Implementation
LToplevelRole *LCompositor::createToplevelRoleRequest(const void *params)
{
return new LToplevelRole(params);
}
virtual LToplevelRole * createToplevelRoleRequest(const void *params)
Virtual constructor for creating LToplevelRole instances when a client creates a toplevel role for a ...

◆ createPopupRoleRequest()

virtual LPopupRole* createPopupRoleRequest ( const void *  params)
virtual

Virtual constructor for creating LPopupRole instances when a client creates a Popup role for a surface.

This method is called when a client creates a Popup role for a surface. The LPopupRole class provides virtual methods to notify changes in geometry, repositioning based on its LPositioner, input grabbing requests, and more.

Parameters
paramsInternal Louvre parameters for creating the Popup role.
Returns
An instance of LPopupRole or a subclass of LPopupRole.
Default Implementation
LPopupRole *LCompositor::createPopupRoleRequest(const void *params)
{
return new LPopupRole(params);
}
virtual LPopupRole * createPopupRoleRequest(const void *params)
Virtual constructor for creating LPopupRole instances when a client creates a Popup role for a surfac...

◆ createSubsurfaceRoleRequest()

virtual LSubsurfaceRole* createSubsurfaceRoleRequest ( const void *  params)
virtual

Virtual constructor for creating LSubsurfaceRole instances when a client creates a Subsurface role for a surface.

This method is called when a client creates a Subsurface role for a surface. The LSubsurfaceRole class provides virtual methods to notify changes in its local position relative to its parent, rearrangement on the stack of sibling surfaces, and more.

Parameters
paramsInternal Louvre parameters for creating the Subsurface role.
Returns
An instance of LSubsurfaceRole or a subclass of LSubsurfaceRole.
Default Implementation
LSubsurfaceRole *LCompositor::createSubsurfaceRoleRequest(const void *params)
{
return new LSubsurfaceRole(params);
}
virtual LSubsurfaceRole * createSubsurfaceRoleRequest(const void *params)
Virtual constructor for creating LSubsurfaceRole instances when a client creates a Subsurface role fo...

◆ createCursorRoleRequest()

virtual LCursorRole* createCursorRoleRequest ( const void *  params)
virtual

Virtual constructor for creating LCursorRole instances when a client wants to use a surface as a cursor.

This method is called when a client wants to use a surface as a cursor by invoking the LPointer::setCursorRequest() method. The LCursorRole class provides a virtual method that notifies changes in the hotspot of the cursor.

Parameters
paramsInternal Louvre parameters for creating the Cursor role.
Returns
An instance of LCursorRole or a subclass of LCursorRole.
Default Implementation
LCursorRole *LCompositor::createCursorRoleRequest(const void *params)
{
return new LCursorRole(params);
}
virtual LCursorRole * createCursorRoleRequest(const void *params)
Virtual constructor for creating LCursorRole instances when a client wants to use a surface as a curs...

◆ createDNDIconRoleRequest()

virtual LDNDIconRole* createDNDIconRoleRequest ( const void *  params)
virtual

Virtual constructor for creating LDNDIconRole instances when a client wants to use a surface as an icon for a Drag & Drop session.

This method is called when a client wants to use a surface as an icon for a Drag & Drop session. Similar to LCursorRole, the LDNDIconRole class provides a virtual method that notifies changes in the hotspot of the icon being dragged.

Parameters
paramsOptional parameters for creating the DND icon role.
Returns
An instance of LDNDIconRole or a subclass of LDNDIconRole.
Default Implementation
LDNDIconRole *LCompositor::createDNDIconRoleRequest(const void *params)
{
return new LDNDIconRole(params);
}
virtual LDNDIconRole * createDNDIconRoleRequest(const void *params)
Virtual constructor for creating LDNDIconRole instances when a client wants to use a surface as an ic...

◆ destroyOutputRequest()

virtual void destroyOutputRequest ( LOutput output)
virtual

Virtual destructor for the LOutput class.

This method is invoked by the graphic backend when an output becomes unavailable.

Note
If the output was initialized, you can be sure its LOutput::uninitializeGL() virtual method is invoked before this event.
Parameters
outputThe LOutput instance to be destroyed.
Default Implementation
void LCompositor::destroyOutputRequest(LOutput *output)
{
L_UNUSED(output);
}
virtual void destroyOutputRequest(LOutput *output)
Virtual destructor for the LOutput class.

◆ destroyClientRequest()

virtual void destroyClientRequest ( LClient client)
virtual

Virtual destructor for the LClient class.

This method is called when a client disconnects, and it is invoked before all its resources have been released.

Parameters
clientThe LClient instance to be destroyed.
Default Implementation
void LCompositor::destroyClientRequest(LClient *client)
{
L_UNUSED(client);
}
virtual void destroyClientRequest(LClient *client)
Virtual destructor for the LClient class.

◆ destroySurfaceRequest()

virtual void destroySurfaceRequest ( LSurface surface)
virtual

Virtual destructor for the LSurface class.

This method is called when a client requests to destroy one of its surfaces.

Parameters
surfaceThe LSurface instance to be destroyed.
Default Implementation
void LCompositor::destroySurfaceRequest(LSurface *surface)
{
L_UNUSED(surface);
}
virtual void destroySurfaceRequest(LSurface *surface)
Virtual destructor for the LSurface class.

◆ destroySeatRequest()

virtual void destroySeatRequest ( LSeat seat)
virtual

Virtual destructor for the LSeat class.

This method is called during the compositor uninitialization.

Parameters
seatThe LSeat instance to be destroyed.
Default Implementation
{
L_UNUSED(seat);
}
virtual void destroySeatRequest(LSeat *seat)
Virtual destructor for the LSeat class.

◆ destroyPointerRequest()

virtual void destroyPointerRequest ( LPointer pointer)
virtual

Virtual destructor for the LPointer class.

This method is called during the compositor uninitialization.

Parameters
pointerThe LPointer instance to be destroyed.
Default Implementation
void LCompositor::destroyPointerRequest(LPointer *pointer)
{
L_UNUSED(pointer);
}
virtual void destroyPointerRequest(LPointer *pointer)
Virtual destructor for the LPointer class.

◆ destroyKeyboardRequest()

virtual void destroyKeyboardRequest ( LKeyboard keyboard)
virtual

Virtual destructor for the LKeyboard class.

This method is called during the compositor uninitialization.

Parameters
keyboardThe LKeyboard instance to be destroyed.
Default Implementation
void LCompositor::destroyKeyboardRequest(LKeyboard *keyboard)
{
L_UNUSED(keyboard);
}
virtual void destroyKeyboardRequest(LKeyboard *keyboard)
Virtual destructor for the LKeyboard class.

◆ destroyDNDManagerRequest()

virtual void destroyDNDManagerRequest ( LDNDManager dndManager)
virtual

Virtual destructor for the LDNDManager class.

This method is called during the compositor uninitialization.

Parameters
dndManagerThe LDNDManager instance to be destroyed.
Default Implementation
void LCompositor::destroyDNDManagerRequest(LDNDManager *dndManager)
{
L_UNUSED(dndManager);
}
virtual void destroyDNDManagerRequest(LDNDManager *dndManager)
Virtual destructor for the LDNDManager class.

◆ destroyToplevelRoleRequest()

virtual void destroyToplevelRoleRequest ( LToplevelRole toplevel)
virtual

Virtual destructor for the LToplevelRole class.

This method is called when a client requests to destroy the toplevel role of one of its surfaces.

Parameters
toplevelThe LToplevelRole instance to be destroyed.
Default Implementation
void LCompositor::destroyToplevelRoleRequest(LToplevelRole *toplevel)
{
L_UNUSED(toplevel);
}
virtual void destroyToplevelRoleRequest(LToplevelRole *toplevel)
Virtual destructor for the LToplevelRole class.

◆ destroyPopupRoleRequest()

virtual void destroyPopupRoleRequest ( LPopupRole popup)
virtual

Virtual destructor for the LPopupRole class.

This method is called when a client requests to destroy the Popup role of one of its surfaces.

Parameters
popupThe LPopupRole instance to be destroyed.
Default Implementation
void LCompositor::destroyPopupRoleRequest(LPopupRole *popup)
{
L_UNUSED(popup);
}
virtual void destroyPopupRoleRequest(LPopupRole *popup)
Virtual destructor for the LPopupRole class.

◆ destroySubsurfaceRoleRequest()

virtual void destroySubsurfaceRoleRequest ( LSubsurfaceRole subsurface)
virtual

Virtual destructor for the LSubsurfaceRole class.

This method is called when a client requests to destroy the Subsurface role of one of its surfaces.

Parameters
subsurfaceThe LSubsurfaceRole instance to be destroyed.
Default Implementation
void LCompositor::destroySubsurfaceRoleRequest(LSubsurfaceRole *subsurface)
{
L_UNUSED(subsurface);
}
virtual void destroySubsurfaceRoleRequest(LSubsurfaceRole *subsurface)
Virtual destructor for the LSubsurfaceRole class.

◆ destroyCursorRoleRequest()

virtual void destroyCursorRoleRequest ( LCursorRole cursor)
virtual

Virtual destructor for the LCursorRole class.

This method is invoked when a client requests to destroy the Cursor role of one of its surfaces.

Parameters
cursorThe LCursorRole instance to be destroyed.
Default Implementation
void LCompositor::destroyCursorRoleRequest(LCursorRole *cursorRole)
{
L_UNUSED(cursorRole);
}
virtual void destroyCursorRoleRequest(LCursorRole *cursor)
Virtual destructor for the LCursorRole class.

◆ destroyDNDIconRoleRequest()

virtual void destroyDNDIconRoleRequest ( LDNDIconRole icon)
virtual

Virtual destructor for the LDNDIconRole class.

This method is invoked when a client requests to destroy the DNDIcon role of one of its surfaces.

Parameters
iconThe LDNDIconRole instance to be destroyed.
Default Implementation
{
L_UNUSED(icon)
}
virtual void destroyDNDIconRoleRequest(LDNDIconRole *icon)
Virtual destructor for the LDNDIconRole class.

◆ start()

bool start ( )

Starts the 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.

Returns
false on failure and true otherwise.

◆ processLoop()

Int32 processLoop ( Int32  msTimeout)

Process the compositor's main event loop.

You can also get a pollable file descriptor with fd().

Parameters
msTimeoutMilliseconds 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.
Returns
1 on success and 0 on failure.

◆ fd()

Int32 fd ( ) const

Get a pollable file descriptor of the main event loop.

Returns
The pollable file descriptor.

◆ finish()

void finish ( )

Ends and uninitializes the compositor.

◆ display()

wl_display * display ( )
static

Get the native wl_display used by the compositor.

Returns
The native wl_display.

◆ eventLoop()

wl_event_loop * eventLoop ( )
static

Get the main wl_event_loop used by the compositor.

Returns
The main wl_event_loop.

◆ addFdListener()

wl_event_source * addFdListener ( int  fd,
void *  userData,
int(*)(int, unsigned int, void *)  callback,
UInt32  flags = WL_EVENT_READABLE 
)
static

Add a pollable file descriptor to the compositor's event loop.

Parameters
fdThe file descriptor to be added.
userDataUser data to pass to the callback function.
callbackThe callback function to handle events on the file descriptor.
flagsFlags to specify the type of event to listen for (e.g., WL_EVENT_READABLE).
Note
If the compositor is suspended, events are queued and will be dispatched once it is resumed.
Returns
The wl_event_source associated with the added file descriptor.

◆ removeFdListener()

void removeFdListener ( wl_event_source *  source)
static

Removes a previously added file descriptor from the compositor's event loop.

Parameters
sourceThe wl_event_source to remove.

◆ cursor()

LCursor * cursor ( ) const

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.

Returns
A pointer to the LCursor instance or nullptr if not yet initialized.

◆ seat()

LSeat * seat ( ) const

Gets the compositor seat.

The seat provides access to the LPointer, LKeyboard, LTouch, and LOutput instances.

Returns
A pointer to the LSeat instance.

◆ repaintAllOutputs()

void repaintAllOutputs ( )

Schedule a new rendering frame for each output in the compositor.

This method schedules a new rendering frame by calling the LOutput::repaint() method for all initialized outputs.

◆ addOutput()

bool addOutput ( LOutput output)

Initializes the specified output.

This method initializes the specified output for rendering, allowing you to schedule rendering frames using the LOutput::repaint() method. The list of initialized outputs can be accessed with the outputs() method.

Note
Adding an already initialized output is a no-op.
Parameters
outputThe output to initialize, obtained from LSeat::outputs().
Returns
true on success, false on failure.

◆ removeOutput()

void removeOutput ( LOutput output)

Uninitializes the specified output.

This method uninitializes and removes the specified output from the compositor, stopping its thread and rendering loop.

Note
Removing an output that has not been added to the compositor is a no-op.
Warning
Calling this method from the same rendering thread of the output (whithin any of its ...GL() events) has no effect. Doing so would lead to a deadlock, so Louvre simply ignores the request.
Parameters
outputThe output to remove, previously added to the compositor.

◆ surfaces()

const std::list< LSurface * > & surfaces ( ) const

Get a list of all surfaces created by clients.

This method returns a list of all surfaces created by clients, respecting the stacking order of their roles/protocols. To access surfaces created by a specific client, use the LClient::surfaces() method instead.

Returns
A list of LSurface objects representing the surfaces.

◆ outputs()

const std::vector< LOutput * > & outputs ( ) const

Get a list of all initialized outputs.

This method returns a list of all outputs that have been initialized using the addOutput() method.

Note
This list only contains initialized outputs. To get a list of all available outputs, use LSeat::outputs() instead.
Returns
A list of LOutput objects representing the initialized outputs.

◆ clients()

const std::vector< LClient * > & clients ( ) const

Get a list of clients connected to the compositor.

This method returns a list of clients that are currently connected to the compositor.

Returns
A list of LClient objects representing the connected clients.

◆ nextSerial()

UInt32 nextSerial ( )
static

Get a new positive integer number, incrementally.

Deprecated:
This method will be removed in Louvre v2.0.0-1. Use LTime::nextSerial() instead.

This method returns a new positive integer number each time it is called, incrementally.

Returns
The next positive integer in the sequence.

◆ eglDisplay()

EGLDisplay eglDisplay ( )
static

Get the main EGL display created by the graphic backend.

This method returns the main EGL display created by the graphic backend.

Returns
The main EGL display.

◆ eglContext()

EGLContext eglContext ( )
static

Get the main EGL context created by the graphic backend.

This method returns the main EGL context created by the graphic backend.

Returns
The main EGL context.

◆ flushClients()

void flushClients ( )
static

Flush all pending client events.

This method immediatly flushes all pending client events.

◆ getClientFromNativeResource()

LClient * getClientFromNativeResource ( wl_client *  client)

Gets the LClient of a native Wayland wl_client resource.

Returns
The LClient instance for a wl_client resource or nullptr if not found.

◆ mainThreadId()

std::thread::id mainThreadId ( ) const

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.

Returns
The identifier of the main thread.