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

Group of input and output devices. More...

+ Inheritance diagram for LSeat:

Public Member Functions

 LSeat (const void *params)
 Constructor of the LSeat class. More...
 ~LSeat ()
 Destructor of the LSeat class. More...
const std::vector< LOutput * > & outputs () const noexcept
 Vector of available outputs. More...
const std::vector< LInputDevice * > & inputDevices () const noexcept
 Vector of available input devices. More...
const char * name () const noexcept
 The seat name. More...
LToplevelRoleactiveToplevel () const noexcept
 Active toplevel surface. More...
const std::vector< LToplevelResizeSession * > & toplevelResizeSessions () const noexcept
 Active LToplevelRole resize sessions. More...
const std::vector< LToplevelMoveSession * > & toplevelMoveSessions () const noexcept
 Active LToplevelRole move sessions. More...
LPointerpointer () const noexcept
 Access to pointer events. More...
LKeyboardkeyboard () const noexcept
 Access to keyboard events. More...
LTouchtouch () const noexcept
 Access to touch events. More...
LDNDdnd () const noexcept
 Access to the drag & drop session manager. More...
LClipboardclipboard () const noexcept
 Access to the clipboard manager. More...
void dismissPopups () noexcept
 Close all popups. More...
LPopupRoletopmostPopup () const noexcept
 Retrieve the topmost popup role. 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...


void setTTY (UInt32 tty) noexcept
 Switches session. More...
Int32 openDevice (const char *path, Int32 *fd) noexcept
 Open a device. More...
Int32 closeDevice (Int32 id) noexcept
 Closes a device. More...
libseat * libseatHandle () const noexcept
 Libseat handle. More...
bool enabled () const noexcept
 Check the session state. More...

Virtual Methods

virtual void nativeInputEvent (void *event)
 Native input backend events. More...
virtual void enabledChanged ()
 Notify a change in the enabled() property. More...
virtual void outputPlugged (LOutput *output)
 New available output. More...
virtual void outputUnplugged (LOutput *output)
 Disconnected output. More...
virtual void inputDevicePlugged (LInputDevice *device)
 New available input device. More...
virtual void inputDeviceUnplugged (LInputDevice *device)
 Disconnected input device. 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

Group of input and output devices.

The LSeat class represents a collection of input and output devices such as a mouse, keyboard, touch screen, and displays (outputs). These devices are used within a session. Typically, for security reasons, access to these devices is restricted to a single process per session, often a Wayland compositor or X11 server.

To enable the libinput and DRM backends to manage devices without requiring superuser privileges, the openDevice() method is used to obtain device file descriptors. This method internally employs libseat.

By setting the environment variable LOUVRE_ENABLE_LIBSEAT to 0, libseat can be disabled, causing the compositor to launch without multi-session support. Consequently, certain features such as switching to another TTY may become unavailable.

Disabling libseat may be necessary in scenarios where the compositor needs to be started remotely via SSH.

Constructor & Destructor Documentation

◆ LSeat()

LSeat ( const void *  params)

Constructor of the LSeat class.

paramsInternal parameters provided in LCompositor::createObjectRequest().

◆ ~LSeat()

~LSeat ( )

Destructor of the LSeat class.

Invoked after LCompositor::onAnticipatedObjectDestruction().

Member Function Documentation

◆ outputs()

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

Vector of available outputs.

This method provides a vector of currently available outputs. The vector includes connected outputs that can be initialized as well as those that are already initialized.
To obtain only initialized outputs, refer to LCompositor::outputs().

◆ inputDevices()

const std::vector< LInputDevice * > & inputDevices ( ) const

Vector of available input devices.

See also
inputDevicePlugged() and inputDeviceUnplugged().

◆ name()

const char * name ( ) const

The seat name.

This method returns the name of the seat (E.g. "seat0").

◆ activeToplevel()

LToplevelRole * activeToplevel ( ) const

Active toplevel surface.

This method returns the current LToplevelRole being configured with the LToplevelRole::State::Activated flag.
Only one toplevel surface can be active at a time, Louvre automatically deactivates other toplevels when one is activated.

The currently active LToplevelRole instance or nullptr if no toplevel is active.

◆ toplevelResizeSessions()

const std::vector< LToplevelResizeSession * > & toplevelResizeSessions ( ) const

◆ toplevelMoveSessions()

const std::vector< LToplevelMoveSession * > & toplevelMoveSessions ( ) const

◆ pointer()

LPointer* pointer ( ) const

Access to pointer events.

Access to the LPointer instance used to receive pointer events from the backend and redirect them to clients.

◆ keyboard()

LKeyboard* keyboard ( ) const

Access to keyboard events.

Access to the LKeyboard instance used to receive keyboard events from the backend and redirect them to clients.

◆ touch()

LTouch* touch ( ) const

Access to touch events.

Access to the LTouch instance used to receive touch events from the backend and redirect them to clients.

◆ dnd()

LDND* dnd ( ) const

Access to the drag & drop session manager.

◆ clipboard()

LClipboard* clipboard ( ) const

Access to the clipboard manager.

◆ dismissPopups()

void dismissPopups ( )

Close all popups.

This method closes all active LPopupRole surfaces in reverse order of creation.

See also

◆ topmostPopup()

LPopupRole * topmostPopup ( ) const

Retrieve the topmost popup role.

This method returns a pointer to the topmost popup.

A pointer to the topmost LPopupRole or nullptr if there is no popup.

◆ setTTY()

void setTTY ( UInt32  tty)

Switches session.

This method allows you to switch to another session (TTY). Louvre also allows switching sessions using the shortcuts Ctrl + Alt + [F1, F2, ..., F10].

ttyTTY number.

◆ openDevice()

Int32 openDevice ( const char *  path,
Int32 fd 

Open a device.

Opens a device returning its ID and storing its file descriptor in fd.
The DRM and Libinput backends use this method to open GPUs and input devices respectively.

pathLocation of the device (E.g. "/dev/dri/card0")
fdStores the file descriptor.
The ID of the device or -1 in case of an error.

◆ closeDevice()

Int32 closeDevice ( Int32  id)

Closes a device.

This method is used by the input and graphic backends to close devices.

idThe id of the device returned by openDevice().
0 if the device is closed successfully and -1 in case of error.

◆ libseatHandle()

libseat * libseatHandle ( ) const

Libseat handle.

struct libseat handle.

Returns nullptr if libseat is not being used.

◆ enabled()

bool enabled ( ) const

Check the session state.

The session is considered disabled if the user is engaged in another active session (TTY).

true if the seat is active, false otherwise.

◆ nativeInputEvent()

virtual void nativeInputEvent ( void *  event)

Native input backend events.

Override this virtual method if you want to access all events generated by the input backend.

eventOpaque handle to the native backend event. When using the Libinput backend it corresponds to a libinput_event struct

Default implementation

void LSeat::nativeInputEvent(void *event)
virtual void nativeInputEvent(void *event)
Native input backend events.

◆ enabledChanged()

virtual void enabledChanged ( )

Notify a change in the enabled() property.

Override this virtual method if you want to be notified when the seat is enabled or disabled.
The seat is enabled when the user is in the session (TTY) in which the compositor is running, and disabled when switching to a different session.

See also

Default implementation

if (!enabled())
cursor()->move(1, 1);
void repaintAllOutputs() noexcept
Unlocks the rendering thread of all initialized outputs.
Definition: LCompositor.cpp:436
void setVisible(bool state) noexcept
Toggles the cursor visibility.
Definition: LCursor.cpp:268
void move(Float32 dx, Float32 dy) noexcept
Moves the cursor.
Definition: LCursor.cpp:209
bool enabled() const noexcept
Check the session state.
Definition: LSeat.cpp:152
virtual void enabledChanged()
Notify a change in the enabled() property.
LCursor * cursor() noexcept
Gets the compositor's cursor.
Definition: LCompositor.cpp:44
LCompositor * compositor() noexcept
Gets the static LCompositor instance.
Definition: LCompositor.cpp:34

◆ outputPlugged()

virtual void outputPlugged ( LOutput output)

New available output.

This event is invoked by the graphic backend when a new output is available, for example when connecting an external monitor through an HDMI port.
The default implementation initializes the new output and positions it at the end (right) of the already initialized outputs.

Default Implementation

void LSeat::outputPlugged(LOutput *output)
output->setScale(output->dpi() >= 200 ? 2 : 1);
if (compositor()->outputs().empty())
output->setPos(compositor()->outputs().back()->pos() + LPoint(compositor()->outputs().back()->size().w(), 0));
bool addOutput(LOutput *output)
Initializes the specified output.
Definition: LCompositor.cpp:442
const std::vector< LOutput * > & outputs() const noexcept
Vector of available outputs.
Definition: LSeat.cpp:60
virtual void outputPlugged(LOutput *output)
New available output.
LPointTemplate< Int32 > LPoint
2D vector of 32 bits integers
Definition: LNamespaces.h:238

◆ outputUnplugged()

virtual void outputUnplugged ( LOutput output)

Disconnected output.

This event is invoked by the graphic backend when an output is no longer available, for example when an external monitor connected to an HDMI port is disconnected.

The default implementation removes the output from the compositor and re-arranges the ones already initialized.

Louvre automatically employs LCompositor::removeOutput() after this event, so calling it directly is not mandatory.

Default Implementation

void LSeat::outputUnplugged(LOutput *output)
Int32 totalWidth { 0 };
for (LOutput *o : compositor()->outputs())
o->setPos(LPoint(totalWidth, 0));
totalWidth += o->size().w();
void removeOutput(LOutput *output)
Uninitializes the specified output.
Definition: LCompositor.cpp:468
virtual void outputUnplugged(LOutput *output)
Disconnected output.
int32_t Int32
32 bits signed integer
Definition: LNamespaces.h:205

◆ inputDevicePlugged()

virtual void inputDevicePlugged ( LInputDevice device)

New available input device.

Default Implementation

void LSeat::inputDevicePlugged(LInputDevice *device)
virtual void inputDevicePlugged(LInputDevice *device)
New available input device.

◆ inputDeviceUnplugged()

virtual void inputDeviceUnplugged ( LInputDevice device)

Disconnected input device.

Default Implementation

void LSeat::inputDeviceUnplugged(LInputDevice *device)
virtual void inputDeviceUnplugged(LInputDevice *device)
Disconnected input device.