Louvre
v2.12.0-1
C++ library for Wayland compositors
|
Class for handling keyboard events. More...
Public Member Functions | |
LKeyboard (const void *params) noexcept | |
Constructor of the LKeyboard class. More... | |
~LKeyboard () | |
Destructor of the LKeyboard class. More... | |
void | setFocus (LSurface *surface) |
Set keyboard focus. More... | |
LSurface * | focus () const noexcept |
Focused surface. More... | |
void | setGrab (LSurface *surface) |
Sets a keyboard grab. More... | |
LSurface * | grab () const noexcept |
Gets the grab surface. More... | |
const LKeyboardModifiersEvent::Modifiers & | modifiers () const noexcept |
Current keyboard modifiers state. More... | |
Int32 | keymapFd () const noexcept |
Keyboard map file descriptor. More... | |
Int32 | keymapSize () const noexcept |
Size of the keyboard map in bytes. More... | |
UInt32 | keymapFormat () const noexcept |
Keymap format. More... | |
Int32 | repeatRate () const noexcept |
Repetition rate. More... | |
Int32 | repeatDelay () const noexcept |
Repetition delay. More... | |
void | setRepeatInfo (Int32 rate, Int32 msDelay) noexcept |
Set the key repeat rate and delay. More... | |
xkb_keysym_t | keySymbol (UInt32 keyCode) noexcept |
Key symbol. More... | |
xkb_state * | keymapState () const noexcept |
Keymap state. More... | |
bool | isModActive (const char *name, xkb_state_component type) const noexcept |
Checks the state of a modifier. More... | |
const std::vector< UInt32 > & | pressedKeys () const noexcept |
All currently pressed key codes. More... | |
bool | isKeyCodePressed (UInt32 keyCode) const noexcept |
Checks if a key code is pressed. More... | |
bool | isKeySymbolPressed (xkb_keysym_t keySymbol) const noexcept |
Check if a key symbol is pressed. More... | |
bool | setKeymap (const char *rules=nullptr, const char *model=nullptr, const char *layout=nullptr, const char *variant=nullptr, const char *options=nullptr) noexcept |
Sets the keyboard map. More... | |
void | sendKeyEvent (const LKeyboardKeyEvent &event) noexcept |
Sends a key event to the currently focused surface. 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... | |
LObject & | operator= (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... | |
Virtual Methods | |
virtual void | keyEvent (const LKeyboardKeyEvent &event) |
Keyboard key event generated by the input backend. More... | |
virtual void | focusChanged () |
Notifies that the focused surface has changed. 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... | |
Class for handling keyboard events.
The LKeyboard class lets you handle keyboard events generated by the input backend, redirect them to clients, and configure parameters such as the keyboard map and key repeat rate.
There is a single instance of LKeyboard, which can be accessed from LSeat::keyboard().
To send keyboard events to clients, you must first assign focus to a surface using setFocus() and then all subsequent keyboard events sent with sendKeyEvent() will be directed to that surface.
|
noexcept |
Constructor of the LKeyboard class.
There is a single instance of LKeyboard, which can be accessed from LSeat::keyboard().
params | Internal parameters provided in LCompositor::createObjectRequest(). |
~LKeyboard | ( | ) |
Destructor of the LKeyboard class.
Invoked after LCompositor::onAnticipatedObjectDestruction().
void setFocus | ( | LSurface * | surface | ) |
Set keyboard focus.
This method assigns keyboard focus to the specified surface. Only one surface can have keyboard focus at a time, and this method automatically removes focus from any previously focused surface.
To remove focus from all surfaces, pass nullptr
as the argument.
|
noexcept |
Focused surface.
nullptr
if no surface has keyboard focus. void setGrab | ( | LSurface * | surface | ) |
Sets a keyboard grab.
Setting a keyboard grab prevents other surfaces from gain focus with setFocus().
If the surface grabbing the keyboard is destroyed the grab is automatically assigned to its parent or unset if it has no parent.
For example, an LPopupRole can request to make a keyboard grab with LPopupRole::grabKeyboardRequest().
If 'surface' is set to nullptr
, the keyboard grab is unset.
surface | The surface that will grab the keyboard events or nullptr to disable it. |
|
noexcept |
|
noexcept |
Current keyboard modifiers state.
|
noexcept |
Keyboard map file descriptor.
File descriptor of the XKB keyboard map assigned with setKeymap().
|
noexcept |
Size of the keyboard map in bytes.
Size in bytes of the XKB keyboard map loaded with setKeymap().
|
noexcept |
Keymap format.
The keymap format can be either WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1
, which indicates the presence of a valid XKB keymap set, or WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP
, indicating an issue with the XKB system configuration.
|
noexcept |
Repetition rate.
Number of repetitions per second of a key when held down, assigned with setRepeatInfo().
The default value is 32 repetitions per second.
|
noexcept |
Repetition delay.
Delay in milliseconds before triggering the repetition of a key by holding it down, set with setRepeatInfo().
The default value is 500 ms.
Set the key repeat rate and delay.
Assigns the repeat rate and delay when holding down a key.
rate | Number of repetitions per second. 0 turns off repetition. |
msDelay | Delay in milliseconds before triggering the replay. |
|
noexcept |
Key symbol.
Returns the symbol of a raw key code generated by the input backend according to the current keymap state.
The complete list of symbols can be found in <xkbcommon/xkbcommon-keysyms.h>
.
|
noexcept |
Keymap state.
XKB keyboard map state.
|
noexcept |
Checks the state of a modifier.
name | Modifier name defined in <xkbcommon/xkbcommon_names.h> such as XKB_MOD_NAME_SHIFT , XKB_LED_NAME_CAPS , etc. |
type | In XKB, the XKB_STATE_MODS_DEPRESSED , XKB_STATE_MODS_LATCHED , XKB_STATE_MODS_LOCKED , and XKB_STATE_MODS_EFFECTIVE are flags used to represent different aspects of the keyboard modifier keys' states. |
XKB_STATE_MODS_DEPRESSED: This flag represents the currently depressed (pressed down) modifiers. When a modifier key is pressed, it falls into the depressed state. This flag helps identify which modifiers are currently held down.
XKB_STATE_MODS_LATCHED: This flag represents modifiers that are latched. A latched modifier is one that will be activated with the next non-modifier key press. Once the latched modifier is used, it returns to its original state.
XKB_STATE_MODS_LOCKED: This flag represents modifiers that are locked. When a modifier is locked, it stays active until explicitly unlocked. For example, if Caps Lock is activated, the Caps Lock state is locked until Caps Lock is pressed again.
XKB_STATE_MODS_EFFECTIVE: This flag represents the effective state of the modifiers. It takes into account the depressed, latched, and locked states to provide a combined view of the current modifier key states.
true
if the modifier is active and false
otherwise.
|
noexcept |
All currently pressed key codes.
|
noexcept |
Checks if a key code is pressed.
|
noexcept |
Check if a key symbol is pressed.
|
noexcept |
Sets the keyboard map.
This method finds and assigns a keyboard map that matches the parameters passed in the arguments.
The keyboard map is automatically sent to clients when they connect to the compositor and use the wl_keyboard interface of the Wayland protocol. If a client is already connected, Louvre re-sends it the new keyboard map.
rules | Rules on how to interpret the other arguments. Can be nullptr . More information. |
model | Keyboard model. Can be nullptr . More information. |
layout | Keyboard layouts separated by comma (e.g. "latam"). Can be nullptr . More information. |
variant | Variants of layouts. Can be nullptr . More information. |
options | Preferences not related to layouts. Can be nullptr . More information. |
|
noexcept |
Sends a key event to the currently focused surface.
|
virtual |
Keyboard key event generated by the input backend.
|
virtual |
Notifies that the focused surface has changed.