Louvre
v1.2.1-2
C++ library for Wayland compositors
|
#include <LSeat.h>
Group of input and output devices. More...
Group of input and output devices.
The LSeat class represents a collection of input and output devices such as a mouse, keyboard, and outputs (screens). These devices are used within a session. Typically, access to these devices is restricted to a single process per session, often a Wayland or X11 compositor.
To enable input and graphics backends to manage seat devices without requiring superuser privileges, the openDevice() method can be used to obtain device file descriptors. This method internally employs libseat to request seat permissions.
By setting the environment variable LOUVRE_ENABLE_LIBSEAT to 0, libseat can be disabled, causing the compositor to launch without multi-seat support. Consequently, certain features such as switching to another TTY may become unavailable.
The LSeat class also facilitates tasks such as session (TTY) switching, clipboard access, interaction with instances of LPointer and LKeyboard, as well as native events monitoring from the input backend.
Public Types | |
enum | InputCapabilities : InputCapabilitiesFlags |
Input capabilities. More... | |
using | InputCapabilitiesFlags = UInt32 |
Public Member Functions | |
LSeat (const void *params) | |
LSeat class constructor. More... | |
virtual | ~LSeat () |
LSeat class destructor. More... | |
const std::vector< LOutput * > & | outputs () const |
Vector of available outputs. More... | |
void * | graphicBackendContextHandle () const |
Handle to the native context used by the graphic backend. More... | |
UInt32 | graphicBackendId () const |
Get the ID of the current graphic backend. More... | |
void * | inputBackendContextHandle () const |
Handle to the native context used by the input backend. More... | |
UInt32 | inputBackendId () const |
Get the ID of the current input backend. More... | |
InputCapabilitiesFlags | inputBackendCapabilities () const |
Input Backend Capabilities. More... | |
const char * | name () const |
The seat name. More... | |
InputCapabilitiesFlags | inputCapabilities () const |
Input capabilities of the compositor. More... | |
void | setInputCapabilities (InputCapabilitiesFlags capabilitiesFlags) |
Assigns the input capabilities of the compositor. More... | |
LToplevelRole * | activeToplevel () const |
Active toplevel surface. More... | |
LPointer * | pointer () const |
Access to pointer events. More... | |
LKeyboard * | keyboard () const |
Access to keyboard events. More... | |
LDNDManager * | dndManager () const |
Access to the drag & drop session manager. More... | |
LDataSource * | dataSelection () const |
Access to the clipboard. More... | |
Session | |
void | setTTY (UInt32 tty) |
Switch session. More... | |
Int32 | openDevice (const char *path, Int32 *fd) |
Open a device. More... | |
Int32 | closeDevice (Int32 id) |
Close a device. More... | |
libseat * | libseatHandle () const |
Libseat handle. More... | |
bool | enabled () const |
Check the session state. More... | |
LPopupRole * | topmostPopup () const |
Retrieve the topmost popup role. More... | |
Virtual Methods | |
virtual void | initialized () |
Seat initialization. More... | |
virtual bool | setSelectionRequest (LDataDevice *device) |
Request to set the clipboard. More... | |
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... | |
Public Member Functions inherited from LObject | |
LObject ()=default | |
Constructor of the LObject class. More... | |
~LObject () | |
Destructor of the LObject class. More... | |
std::shared_ptr< const bool > | isAlive () const |
Object's liveness status. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from LObject | |
static LCompositor * | compositor () |
Quick access to the global compositor instance. More... | |
static LSeat * | seat () |
Quick access to the global seat instance. More... | |
static LCursor * | cursor () |
Quick access to the global cursor instance. More... | |
using InputCapabilitiesFlags = UInt32 |
LSeat | ( | const void * | params | ) |
LSeat class constructor.
There is only one instance of LSeat, which can be accessed from LCompositor::seat().
params | Internal library parameters provided in the virtual LCompositor::createSeatRequest() constructor. |
|
virtual |
LSeat class destructor.
Invoked after LCompositor::destroySeatRequest().
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().
void * graphicBackendContextHandle | ( | ) | const |
Handle to the native context used by the graphic backend.
This opaque handle is unique to each graphic backend.
In the case of the DRM backend, it returns a pointer to a SRMCore struct.
In the case of the X11 backend, it returns a pointer to a Display struct.
You can use this handle to configure specific aspects of each backend.
UInt32 graphicBackendId | ( | ) | const |
Get the ID of the current graphic backend.
Each graphic backend is assigned a unique Louvre::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 Louvre::LGraphicBackendID enum.
void * inputBackendContextHandle | ( | ) | const |
Handle to the native context used by the input backend.
This opaque handle is unique to each input backend.
In the case of the Libinput backend, it returns a pointer to a libinput struct.
In the case of the X11 backend, it returns a pointer to a Display struct.
You can use this handle to configure specific aspects of each backend.
UInt32 inputBackendId | ( | ) | const |
Get 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.
LSeat::InputCapabilitiesFlags inputBackendCapabilities | ( | ) | const |
Input Backend Capabilities.
Flags representing the input capabilities of the input backend, defined in Louvre::LSeat::InputCapabilities.
const char * name | ( | ) | const |
The seat name.
This method returns the name of the seat (E.g. "seat0").
LSeat::InputCapabilitiesFlags inputCapabilities | ( | ) | const |
Input capabilities of the compositor.
Flags with the input capabilities of the compositor assigned with setInputCapabilities().
void setInputCapabilities | ( | LSeat::InputCapabilitiesFlags | capabilitiesFlags | ) |
Assigns the input capabilities of the compositor.
This method notifies clients about the compositor's input capabilities.
Clients will only listen to events specified in the capabilities flags.
The default implementation of initialized() sets the compositor's capabilities to those of the input backend.
capabilitiesFlags | Flags with the input capabilities of the compositor defined in Louvre::LSeat::InputCapabilities. They may differ from the input capabilities of the input backend. |
LToplevelRole * activeToplevel | ( | ) | const |
Active toplevel surface.
This method returns the active LToplevelRole role assigned by passing the flag Louvre::LToplevelRole::Activated in Louvre::LToplevelRole::confgure().
Only one toplevel surface can be active at a time, the library automatically deactivates other Toplevels when one is activated.
nullptr
if no toplevel is active. 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.
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.
LDNDManager * dndManager | ( | ) | const |
Access to the drag & drop session manager.
Access to the LDNDManager instance used to handle drag & drop sessions.
LDataSource * dataSelection | ( | ) | const |
Access to the clipboard.
Access to the clipboard (data source) assigned by the last client.
nullptr
if the clipboard has not been assigned. void setTTY | ( | UInt32 | tty | ) |
Switch session.
This method allows you to switch to another session (TTY). Louvre also allows switching sessions using the shortcuts Ctrl + Alt + [F1, F2, ..., F10]
.
tty | TTY number. |
Open a device.
Opens a device on the seat, returning its ID and storing its file descriptor in fd.
The DRM graphic backend and the Libinput input backend use this method to open GPUs and input devices respectively.
path | Location of the device (E.g. "/dev/dri/card0") |
fd | Stores the file descriptor. |
Close a device.
This method is used by the input and graphic backends to close devices.
id | The id of the device returned by openDevice(). |
libseat * libseatHandle | ( | ) | const |
Libseat handle.
struct libseat handle.
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. LPopupRole * topmostPopup | ( | ) | const |
Retrieve the topmost popup role.
This method returns a pointer to the topmost popup.
nullptr
if there is no popup.
|
virtual |
Seat initialization.
Reimplement this virtual method if you want to be notified when the seat is initialized.
The seat is initialized during the compositor's initialization process.
|
virtual |
Request to set the clipboard.
Reimplement this virtual method if you want to control which clients can set the clipboard.
The default implementation allows clients to set the clipboard only if one of their surfaces has pointer or keyboard focus.
Returning true
grants the client permission to set the clipboard and false
prohibits it.
device | Data device that makes the request. |
|
virtual |
Native input backend events.
Reimplement this virtual method if you want to access all events generated by the input backend.
event | Opaque handle to the native backend event. In the Libinput backend it corresponds to a libinput_event struct and in the X11 backend to a XEvent struct. |
|
virtual |
Notify a change in the enabled() property.
Reimplement 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.
|
virtual |
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.
You can reimplement this method to be notified when a new output is available.
The default implementation initializes the new output and positions it at the end (right) of the already initialized outputs.
|
virtual |
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.
You can override this method to be notified when an output is no longer available.
The default implementation removes the output from the compositor if it is initialized and re-arranges the ones already initialized.