Louvre  v2.13.0-1
C++ library for Wayland compositors
Classes | Public Member Functions | List of all members
LClient Class Reference

Representation of a Wayland client. More...

+ Inheritance diagram for LClient:

Classes

struct  EventHistory
 Structure containing the last events sent to the client. More...
 
struct  KeyboardHistory
 Keyboard event history. More...
 
struct  PointerHistory
 Pointer event history. More...
 
struct  TouchHistory
 Touch event history. More...
 

Public Member Functions

 LClient (const void *params) noexcept
 Constructor of the LClient class. More...
 
 ~LClient ()
 Destructor of the LClient class. More...
 
void credentials (pid_t *pid, uid_t *uid=nullptr, gid_t *gid=nullptr) const noexcept
 Retrieves Unix credentials of the client. More...
 
bool ping (UInt32 serial) const noexcept
 Sends a ping event to the client. More...
 
virtual void pong (UInt32 serial)
 Client response to a ping() event. More...
 
wl_client * client () const noexcept
 Native wl_client struct of the client. More...
 
void flush () noexcept
 Immediately flushes pending events. More...
 
void destroyLater () noexcept
 Terminates the client connection with the compositor. More...
 
const EventHistoryeventHistory () const noexcept
 Retrieves the client's event history. More...
 
const LEventfindEventBySerial (UInt32 serial) const noexcept
 Finds an event sent by the compositor matching the given serial number. More...
 
const LClientCursorlastCursorRequest () const noexcept
 Retrieves the last cursor requested by the client. More...
 
const std::vector< Protocols::Wayland::GOutput * > & outputGlobals () const noexcept
 
const std::vector< Protocols::Wayland::GCompositor * > & compositorGlobals () const noexcept
 
const std::vector< Protocols::Wayland::GSubcompositor * > & subcompositorGlobals () const noexcept
 
const std::vector< Protocols::Wayland::GSeat * > & seatGlobals () const noexcept
 
const std::vector< Protocols::Wayland::GDataDeviceManager * > & dataDeviceManagerGlobals () const noexcept
 
const std::vector< Protocols::XdgShell::GXdgWmBase * > & xdgWmBaseGlobals () const noexcept
 
const std::vector< Protocols::XdgDecoration::GXdgDecorationManager * > & xdgDecorationManagerGlobals () const noexcept
 
const std::vector< Protocols::PresentationTime::GPresentation * > & presentationTimeGlobals () const noexcept
 
const std::vector< Protocols::LinuxDMABuf::GLinuxDMABuf * > & linuxDMABufGlobals () const noexcept
 
const std::vector< Protocols::Viewporter::GViewporter * > & viewporterGlobals () const noexcept
 
const std::vector< Protocols::FractionalScale::GFractionalScaleManager * > & fractionalScaleManagerGlobals () const noexcept
 
const std::vector< Protocols::GammaControl::GGammaControlManager * > & gammaControlManagerGlobals () const noexcept
 
const std::vector< Protocols::TearingControl::GTearingControlManager * > & tearingControlManagerGlobals () const noexcept
 
const std::vector< Protocols::RelativePointer::GRelativePointerManager * > & relativePointerManagerGlobals () const noexcept
 
const std::vector< Protocols::PointerGestures::GPointerGestures * > & pointerGesturesGlobals () const noexcept
 
const std::vector< Protocols::SessionLock::GSessionLockManager * > & sessionLockManagerGlobals () const noexcept
 
const std::vector< Protocols::PointerConstraints::GPointerConstraints * > & pointerConstraintsGlobals () const noexcept
 
const std::vector< Protocols::XdgOutput::GXdgOutputManager * > & xdgOutputManagerGlobals () const noexcept
 
const std::vector< Protocols::ScreenCopy::GScreenCopyManager * > & screenCopyManagerGlobals () const noexcept
 
const std::vector< Protocols::ImageCaptureSource::GOutputImageCaptureSourceManager * > & outputImageCaptureSourceManagerGlobals () const noexcept
 
const std::vector< Protocols::ImageCaptureSource::GForeignToplevelImageCaptureSourceManager * > & foreignToplevelImageCaptureSourceManagerGlobals () const noexcept
 
const std::vector< Protocols::LayerShell::GLayerShell * > & layerShellGlobals () const noexcept
 
const std::vector< Protocols::ForeignToplevelManagement::GForeignToplevelManager * > & foreignToplevelManagerGlobals () const noexcept
 
const std::vector< Protocols::ForeignToplevelList::GForeignToplevelList * > & foreignToplevelListGlobals () const noexcept
 
const std::vector< Protocols::SinglePixelBuffer::GSinglePixelBufferManager * > & singlePixelBufferManagerGlobals () const noexcept
 
const std::vector< Protocols::ContentType::GContentTypeManager * > & contentTypeManagerGlobals () const noexcept
 
const std::vector< Protocols::IdleNotify::GIdleNotifier * > & idleNotifierGlobals () const noexcept
 
const std::vector< Protocols::IdleInhibit::GIdleInhibitManager * > & idleInhibitManagerGlobals () const noexcept
 
const std::vector< Protocols::XdgActivation::GXdgActivation * > & xdgActivationGlobals () const noexcept
 
const std::vector< Protocols::DRMLease::GDRMLeaseDevice * > & drmLeaseDeviceGlobals () const noexcept
 
const std::vector< Protocols::WlrOutputManagement::GWlrOutputManager * > & wlrOutputManagerGlobals () const noexcept
 
- 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

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

Detailed Description

Representation of a Wayland client.

The LClient class represents a Wayland client connected to the compositor.
It allows managing the client connection, accessing its resources created through various Wayland protocols, handling ping/pong events, and more.


Class Documentation

◆ Louvre::LClient::EventHistory

struct Louvre::LClient::EventHistory

Structure containing the last events sent to the client.

This structure only contains event types that have a serial number in their respective Wayland protocol interface.

Class Members
PointerHistory pointer Pointer event history.
KeyboardHistory keyboard Keyboard event history.
TouchHistory touch Touch event history.

◆ Louvre::LClient::KeyboardHistory

struct Louvre::LClient::KeyboardHistory

Keyboard event history.

Class Members
LKeyboardEnterEvent enter Sent when a surface acquires keyboard focus.
LKeyboardKeyEvent key[5] Ring buffer of the last 5 keyboard key events.
UInt8 keyIndex Current index of the keyboard key ring buffer.
LKeyboardLeaveEvent leave Sent when a surface loses keyboard focus.
LKeyboardModifiersEvent modifiers Sent when keyboard modifiers change.

◆ Louvre::LClient::PointerHistory

struct Louvre::LClient::PointerHistory

Pointer event history.

Class Members
LPointerEnterEvent enter Sent when a surface acquires pointer focus.
LPointerLeaveEvent leave Sent when a surface loses pointer focus.
LPointerButtonEvent button[5] Ring buffer of the last 5 pointer button events.
UInt8 buttonIndex Current index of the pointer button ring buffer.
LPointerSwipeBeginEvent swipeBegin Sent when a pointer swipe begins.
LPointerSwipeEndEvent swipeEnd Sent when a pointer swipe ends.
LPointerPinchBeginEvent pinchBegin Sent when a pointer pinch begins.
LPointerPinchEndEvent pinchEnd Sent when a pointer pinch ends.
LPointerHoldBeginEvent holdBegin Sent when a pointer hold begins.
LPointerHoldEndEvent holdEnd Sent when a pointer hold ends.

◆ Louvre::LClient::TouchHistory

struct Louvre::LClient::TouchHistory

Touch event history.

A vector is used to store the last down and up events for specific touch points.
This is because the number of touch points is variable, but they are always re-used.

Class Members
vector< LTouchDownEvent > down Vector of the last touch down events.
vector< LTouchUpEvent > up Vector of the last touch up events.

Constructor & Destructor Documentation

◆ LClient()

LClient ( const void *  params)
noexcept

Constructor of the LClient class.

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

◆ ~LClient()

~LClient ( )

Destructor of the LClient class.

Invoked after LCompositor::onAnticipatedObjectDestruction().

Member Function Documentation

◆ credentials()

void credentials ( pid_t *  pid,
uid_t *  uid = nullptr,
gid_t *  gid = nullptr 
) const
noexcept

Retrieves Unix credentials of the client.

This method allows you to retrieve the process ID (PID), user ID (UID), and group ID (GID) of the client.

See also
wl_client_get_credentials
Parameters
pidA pointer to store the process ID (PID), or nullptr if not needed.
uidA pointer to store the user ID (UID), or nullptr if not needed.
gidA pointer to store the group ID (GID), or nullptr if not needed.

◆ ping()

bool ping ( UInt32  serial) const
noexcept

Sends a ping event to the client.

This method sends a serial number to the client, which is expected to acknowledge it by invoking the pong() virtual method.
It is primarily used to detect if a client is unresponsive.

Note
Not all clients may support this mechanism. If the client does not support it, this method returns false, and you should not wait for a pong() response.
Parameters
serialThe serial number that the client must ACK when calling pong().
Returns
true if the Ping event was sent successfully, false if the client does not support this mechanism.

◆ pong()

virtual void pong ( UInt32  serial)
virtual

Client response to a ping() event.

Override this virtual method if you want to be notified when a client responds to a ping() event.

Parameters
serialThe same serial number passed in ping().
Default Implementation
void LClient::pong(UInt32 serial)
{
L_UNUSED(serial);
/* No default implementation */
}
virtual void pong(UInt32 serial)
Client response to a ping() event.
uint32_t UInt32
32 bits unsigned integer
Definition: LNamespaces.h:214

◆ client()

wl_client * client ( ) const
noexcept

Native wl_client struct of the client.

This method returns a pointer to the native wl_client struct associated with the client. The wl_client struct is part of the original Wayland library.

◆ flush()

void flush ( )
noexcept

Immediately flushes pending events.

Use this method to forcefully and immediately send any pending messages to the client.

◆ destroyLater()

void destroyLater ( )
noexcept

Terminates the client connection with the compositor.

This method terminates the client's connection with the compositor, equivalent to invoking wl_client_destroy().
For safety reasons, it does not occur immediately but at the end of a main loop iteration.

Note
All resources created by the client are automatically destroyed in reverse order of creation.

◆ eventHistory()

const LClient::EventHistory & eventHistory ( ) const
noexcept

Retrieves the client's event history.

This method returns a reference to a structure containing the most recent events that the compositor has sent to the client.
Initially, all events have a serial number of 0, indicating that the compositor has never sent that specific event type.

See also
findEventBySerial()
Returns
A reference to a const EventHistory structure.

◆ findEventBySerial()

const LEvent * findEventBySerial ( UInt32  serial) const
noexcept

Finds an event sent by the compositor matching the given serial number.

This method searches for an event sent by the compositor with the specified serial number in the client's eventHistory().
If a matching event is found, a pointer to that event is returned, otherwise, nullptr.

Note
The returned event pointer must not be manually deleted.
Parameters
serialThe serial number to search for.
Returns
A pointer to the event matching the serial number sent by the compositor, or nullptr if not found.

◆ lastCursorRequest()

const LClientCursor & lastCursorRequest ( ) const
noexcept

Retrieves the last cursor requested by the client.

This method returns a reference to the last cursor that the client requested to set.

See also
LPointer::setCursorRequest()
Returns
A reference to the last cursor requested by the client.

◆ outputGlobals()

const std::vector< Wayland::GOutput * > & outputGlobals ( ) const
noexcept

Resources created when the client binds to the wl_output global.

Note
Louvre internally creates a wl_output global for each initialized output.

◆ compositorGlobals()

const std::vector< Wayland::GCompositor * > & compositorGlobals ( ) const
noexcept

Resources created when the client binds to the wl_compositor singleton global of the Wayland protocol.

◆ subcompositorGlobals()

const std::vector< Wayland::GSubcompositor * > & subcompositorGlobals ( ) const
noexcept

Resources created when the client binds to the wl_subcompositor global of the Wayland protocol.

◆ seatGlobals()

const std::vector< Wayland::GSeat * > & seatGlobals ( ) const
noexcept

Resources created when the client binds to the wl_seat global of the Wayland protocol.

◆ dataDeviceManagerGlobals()

const std::vector< Wayland::GDataDeviceManager * > & dataDeviceManagerGlobals ( ) const
noexcept

Resource created when the client binds to the wl_data_device_manager singleton global of the Wayland protocol.

◆ xdgWmBaseGlobals()

const std::vector< XdgShell::GXdgWmBase * > & xdgWmBaseGlobals ( ) const
noexcept

Resources created when the client binds to the xdg_wm_base global of the XdgShell protocol.

◆ xdgDecorationManagerGlobals()

const std::vector< XdgDecoration::GXdgDecorationManager * > & xdgDecorationManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zxdg_decoration_manager_v1 global of the XdgDecoration protocol.

The zxdg_decoration_manager_v1 interface allows the client and the compositor negotiate who should draw the decoration of toplevel surfaces.

◆ presentationTimeGlobals()

const std::vector< PresentationTime::GPresentation * > & presentationTimeGlobals ( ) const
noexcept

Resources created when the client binds to the wp_presentation global of the PresentationTime protocol.

◆ linuxDMABufGlobals()

const std::vector< LinuxDMABuf::GLinuxDMABuf * > & linuxDMABufGlobals ( ) const
noexcept

Resources created when the client binds to the zwp_linux_dmabuf_v1 global of the LinuxDMA-BUF protocol.

◆ viewporterGlobals()

const std::vector< Viewporter::GViewporter * > & viewporterGlobals ( ) const
noexcept

Resources created when the client binds to the wp_viewporter global of the Viewporter protocol.

◆ fractionalScaleManagerGlobals()

const std::vector< FractionalScale::GFractionalScaleManager * > & fractionalScaleManagerGlobals ( ) const
noexcept

Resources created when the client binds to the wp_fractional_scale_manager_v1 global of the FractionalScale protocol.

◆ gammaControlManagerGlobals()

const std::vector< GammaControl::GGammaControlManager * > & gammaControlManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwlr_gamma_control_manager_v1 global of the wlroots Gamma Control protocol.

◆ tearingControlManagerGlobals()

const std::vector< TearingControl::GTearingControlManager * > & tearingControlManagerGlobals ( ) const
noexcept

Resources created when the client binds to the wp_tearing_control_manager_v1 global of the Tearing Control protocol.

◆ relativePointerManagerGlobals()

const std::vector< RelativePointer::GRelativePointerManager * > & relativePointerManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwp_relative_pointer_manager_v1 global of the Relative Pointer protocol.

◆ pointerGesturesGlobals()

const std::vector< PointerGestures::GPointerGestures * > & pointerGesturesGlobals ( ) const
noexcept

Resources created when the client binds to the zwp_pointer_gestures_v1 global of the Pointer Gestures protocol.

◆ sessionLockManagerGlobals()

const std::vector< SessionLock::GSessionLockManager * > & sessionLockManagerGlobals ( ) const
noexcept

Resources created when the client binds to the ext_session_lock_manager_v1 global of the Session Lock protocol.

◆ pointerConstraintsGlobals()

const std::vector< PointerConstraints::GPointerConstraints * > & pointerConstraintsGlobals ( ) const
noexcept

Resources created when the client binds to the zwp_pointer_constraints_v1 global of the Pointer Constraints protocol.

◆ xdgOutputManagerGlobals()

const std::vector< XdgOutput::GXdgOutputManager * > & xdgOutputManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zxdg_output_manager_v1 global of the XDG Output protocol.

◆ screenCopyManagerGlobals()

const std::vector< ScreenCopy::GScreenCopyManager * > & screenCopyManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwlr_screencopy_manager_v1 global of the wlroots Screen Copy protocol.

◆ outputImageCaptureSourceManagerGlobals()

const std::vector< ImageCaptureSource::GOutputImageCaptureSourceManager * > & outputImageCaptureSourceManagerGlobals ( ) const
noexcept

Resources created when the client binds to the ext_output_image_capture_source_manager_v1 global of the Image Capture Source protocol.

◆ foreignToplevelImageCaptureSourceManagerGlobals()

const std::vector< ImageCaptureSource::GForeignToplevelImageCaptureSourceManager * > & foreignToplevelImageCaptureSourceManagerGlobals ( ) const
noexcept

Resources created when the client binds to the ext_foreign_toplevel_image_capture_source_manager_v1 global of the Image Capture Source protocol.

◆ layerShellGlobals()

const std::vector< LayerShell::GLayerShell * > & layerShellGlobals ( ) const
noexcept

Resources created when the client binds to the zwlr_layer_shell_v1 global of the wlroots Layer Shell protocol.

◆ foreignToplevelManagerGlobals()

const std::vector< ForeignToplevelManagement::GForeignToplevelManager * > & foreignToplevelManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwlr_foreign_toplevel_manager_v1 global of the wlroots Foreign Toplevel Management protocol.

◆ foreignToplevelListGlobals()

const std::vector< ForeignToplevelList::GForeignToplevelList * > & foreignToplevelListGlobals ( ) const
noexcept

Resources created when the client binds to the ext_foreign_toplevel_list_v1 global of the Foreign Toplevel List protocol.

◆ singlePixelBufferManagerGlobals()

const std::vector< SinglePixelBuffer::GSinglePixelBufferManager * > & singlePixelBufferManagerGlobals ( ) const
noexcept

Resources created when the client binds to the wp_single_pixel_buffer_manager_v1 global of the Single Pixel Buffer protocol.

◆ contentTypeManagerGlobals()

const std::vector< ContentType::GContentTypeManager * > & contentTypeManagerGlobals ( ) const
noexcept

Resources created when the client binds to the wp_content_type_manager_v1 global of the Content Type Hint protocol.

◆ idleNotifierGlobals()

const std::vector< IdleNotify::GIdleNotifier * > & idleNotifierGlobals ( ) const
noexcept

Resources created when the client binds to the ext_idle_notifier_v1 global of the Idle Notify protocol.

◆ idleInhibitManagerGlobals()

const std::vector< IdleInhibit::GIdleInhibitManager * > & idleInhibitManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwp_idle_inhibit_manager_v1 global of the Idle Inhibit protocol.

◆ xdgActivationGlobals()

const std::vector< XdgActivation::GXdgActivation * > & xdgActivationGlobals ( ) const
noexcept

Resources created when the client binds to the xdg_activation_v1 global of the XDG Activation protocol.

◆ drmLeaseDeviceGlobals()

const std::vector< DRMLease::GDRMLeaseDevice * > & drmLeaseDeviceGlobals ( ) const
noexcept

Resources created when the client binds to the wp_drm_lease_device_v1 global of the DRM Lease protocol.

◆ wlrOutputManagerGlobals()

const std::vector< WlrOutputManagement::GWlrOutputManager * > & wlrOutputManagerGlobals ( ) const
noexcept

Resources created when the client binds to the zwlr_output_manager_v1 global of the wlroots Output Management protocol.