libei  0.2
A library for Emulated Input
EI - The client API

libei is the client-side module. More...

Data Structures

struct  ei
 The main context to interact with libei. More...
 
struct  ei_device
 A single device to generate input events from. More...
 
struct  ei_seat
 A logical seat for a group of devices. More...
 
struct  ei_event
 An event received from the EIS implementation. More...
 
struct  ei_keymap
 An keymap for a device with the EI_DEVICE_CAP_KEYBOARD capability. More...
 
struct  ei_region
 A rectangular region, defined by an x/y offset and a width and a height. More...
 

Typedefs

typedef void(* ei_log_handler) (struct ei *ei, enum ei_log_priority priority, const char *file, int lineno, const char *func, const char *message, bool is_continuation)
 The log handler for library logging. More...
 

Enumerations

enum  ei_device_type { EI_DEVICE_TYPE_VIRTUAL , EI_DEVICE_TYPE_PHYSICAL }
 The device type determines what the device represents. More...
 
enum  ei_device_capability { EI_DEVICE_CAP_POINTER , EI_DEVICE_CAP_POINTER_ABSOLUTE , EI_DEVICE_CAP_KEYBOARD , EI_DEVICE_CAP_TOUCH }
 The set of supported capabilities. More...
 
enum  ei_property_permission {
  EI_PROPERTY_PERM_NONE , EI_PROPERTY_PERM_READ , EI_PROPERTY_PERM_WRITE , EI_PROPERTY_PERM_DELETE ,
  EI_PROPERTY_PERM_ALL
}
 A set of masks for operations permitted on properties. More...
 
enum  ei_keymap_type { EI_KEYMAP_TYPE_XKB }
 The set of supported keymap types for a struct ei_keymap. More...
 
enum  ei_event_type {
  EI_EVENT_CONNECT , EI_EVENT_DISCONNECT , EI_EVENT_PROPERTY , EI_EVENT_SEAT_ADDED ,
  EI_EVENT_SEAT_REMOVED , EI_EVENT_DEVICE_ADDED , EI_EVENT_DEVICE_REMOVED , EI_EVENT_DEVICE_PAUSED ,
  EI_EVENT_DEVICE_RESUMED , EI_EVENT_KEYBOARD_MODIFIERS , EI_EVENT_FRAME , EI_EVENT_DEVICE_START_EMULATING ,
  EI_EVENT_DEVICE_STOP_EMULATING , EI_EVENT_POINTER_MOTION , EI_EVENT_POINTER_MOTION_ABSOLUTE , EI_EVENT_POINTER_BUTTON ,
  EI_EVENT_POINTER_SCROLL , EI_EVENT_POINTER_SCROLL_STOP , EI_EVENT_POINTER_SCROLL_CANCEL , EI_EVENT_POINTER_SCROLL_DISCRETE ,
  EI_EVENT_KEYBOARD_KEY , EI_EVENT_TOUCH_DOWN , EI_EVENT_TOUCH_UP , EI_EVENT_TOUCH_MOTION
}
 
enum  ei_log_priority { EI_LOG_PRIORITY_DEBUG , EI_LOG_PRIORITY_INFO , EI_LOG_PRIORITY_WARNING , EI_LOG_PRIORITY_ERROR }
 

Functions

struct eiei_new (void *user_data)
 This is an alias for ei_new_sender. More...
 
struct eiei_new_sender (void *user_data)
 Create a new sender ei context. More...
 
struct eiei_new_receiver (void *user_data)
 Create a new receiver ei context. More...
 
bool ei_is_sender (struct ei *ei)
 
void ei_log_set_handler (struct ei *ei, ei_log_handler log_handler)
 Change the log handler for this context. More...
 
void ei_log_set_priority (struct ei *ei, enum ei_log_priority priority)
 
enum ei_log_priority ei_log_get_priority (const struct ei *ei)
 
void ei_configure_name (struct ei *ei, const char *name)
 Set the name for this client. More...
 
int ei_property_set (struct ei *ei, const char *property, const char *value)
 See ei_property_set_with_permissions(), but the permissions are left as-is. More...
 
int ei_property_set_with_permissions (struct ei *ei, const char *property, const char *value, uint32_t permission)
 Change, create or delete a property. More...
 
uint32_t ei_property_get_permissions (struct ei *ei, const char *property)
 Return the permissions mask for the given property. More...
 
const char * ei_property_get (struct ei *ei, const char *property)
 Return the value of the given property or NULL if the property is not set or does not have the EI_PROPERTY_PERM_READ permission. More...
 
int ei_setup_backend_socket (struct ei *ei, const char *socketpath)
 Set this ei context to use the socket backend. More...
 
int ei_setup_backend_fd (struct ei *ei, int fd)
 Initialize the ei context on the given socket. More...
 
int ei_setup_backend_portal (struct ei *ei)
 Connect to the org.freedesktop.portal.Desktop portal. More...
 
int ei_setup_backend_portal_busname (struct ei *ei, const char *busname)
 Connect to an org.freedesktop.portal.Desktop implementation on the given busname. More...
 
struct eiei_ref (struct ei *ei)
 Increase the refcount of this struct by one. More...
 
struct eiei_unref (struct ei *ei)
 Decrease the refcount of this struct by one. More...
 
void ei_set_user_data (struct ei *ei, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_get_user_data (struct ei *ei)
 Return the custom data pointer for this context. More...
 
int ei_get_fd (struct ei *ei)
 libei keeps a single file descriptor for all events. More...
 
void ei_dispatch (struct ei *ei)
 Main event dispatching function. More...
 
struct ei_eventei_get_event (struct ei *ei)
 Return the next event from the event queue, removing it from the queue. More...
 
struct ei_eventei_peek_event (struct ei *ei)
 Returns the next event in the internal event queue (or NULL) without removing that event from the queue; the next call to ei_get_event() will return that same event. More...
 
struct ei_eventei_event_unref (struct ei_event *event)
 Release resources associated with this event. More...
 
const char * ei_seat_get_name (struct ei_seat *seat)
 
bool ei_seat_has_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Return true if the capabilitiy is available on this seat or false otherwise. More...
 
void ei_seat_bind_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Bind this client to the given seat capability. More...
 
 __attribute__ ((sentinel)) void ei_seat_bind_capabilities(struct ei_seat *seat
 Same as ei_seat_bind_capability() but takes multiple capabilities, terminated by NULL. More...
 
void ei_seat_unbind_capability (struct ei_seat *seat, enum ei_device_capability cap)
 Unbind a seat's capability. More...
 
struct ei_seatei_seat_ref (struct ei_seat *seat)
 
struct ei_seatei_seat_unref (struct ei_seat *seat)
 
struct eiei_seat_get_context (struct ei_seat *seat)
 Return the struct EI - the client implementation context this seat is associated with. More...
 
enum ei_event_type ei_event_get_type (struct ei_event *event)
 
struct ei_deviceei_event_get_device (struct ei_event *event)
 Return the device from this event. More...
 
uint64_t ei_event_get_time (struct ei_event *event)
 
uint32_t ei_event_keyboard_get_xkb_mods_depressed (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically pressed-down modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_mods_latched (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically latched modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_mods_locked (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically locked modifiers. More...
 
uint32_t ei_event_keyboard_get_xkb_group (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the logical group state. More...
 
struct ei_deviceei_device_ref (struct ei_device *device)
 Increase the refcount of this struct by one. More...
 
struct ei_deviceei_device_unref (struct ei_device *device)
 Decrease the refcount of this struct by one. More...
 
struct ei_seatei_device_get_seat (struct ei_device *device)
 
void ei_seat_set_user_data (struct ei_seat *seat, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_seat_get_user_data (struct ei_seat *seat)
 Return the custom data pointer for this context. More...
 
void ei_device_set_user_data (struct ei_device *device, void *user_data)
 Set a custom data pointer for this context. More...
 
void * ei_device_get_user_data (struct ei_device *device)
 Return the custom data pointer for this context. More...
 
struct ei_keymapei_device_get_keymap (struct ei_device *device)
 
size_t ei_keymap_get_size (struct ei_keymap *keymap)
 
enum ei_keymap_type ei_keymap_get_type (struct ei_keymap *keymap)
 Returns the type for this keymap. More...
 
int ei_keymap_get_fd (struct ei_keymap *keymap)
 Return a memmap-able file descriptor pointing to the keymap used by the device. More...
 
struct ei_deviceei_keymap_get_device (struct ei_keymap *keymap)
 Return the device this keymap belongs to, or NULL if it has not yet been assigned to a device. More...
 
struct ei_keymapei_keymap_ref (struct ei_keymap *keymap)
 Increase the refcount of this struct by one. More...
 
struct ei_keymapei_keymap_unref (struct ei_keymap *keymap)
 Decrease the refcount of this struct by one. More...
 
void ei_keymap_set_user_data (struct ei_keymap *keymap, void *user_data)
 
void * ei_keymap_get_user_data (struct ei_keymap *keymap)
 
void ei_device_close (struct ei_device *device)
 Notify the server that the client is no longer interested in this device. More...
 
const char * ei_device_get_name (struct ei_device *device)
 
enum ei_device_type ei_device_get_type (struct ei_device *device)
 The device type of the device is determined by the type of the ei context. More...
 
bool ei_device_has_capability (struct ei_device *device, enum ei_device_capability cap)
 Return true if the device has the requested capability. More...
 
struct ei_regionei_device_get_region (struct ei_device *device, size_t index)
 Obtain a region from a device of type EI_DEVICE_TYPE_VIRTUAL. More...
 
struct ei_regionei_region_ref (struct ei_region *region)
 
struct ei_regionei_region_unref (struct ei_region *region)
 
void ei_region_set_user_data (struct ei_region *region, void *user_data)
 
void * ei_region_get_user_data (struct ei_region *region)
 
uint32_t ei_region_get_x (struct ei_region *region)
 
uint32_t ei_region_get_y (struct ei_region *region)
 
uint32_t ei_region_get_width (struct ei_region *region)
 
uint32_t ei_region_get_height (struct ei_region *region)
 
bool ei_region_contains (struct ei_region *region, double x, double y)
 Return true if the point x/y (in desktop-wide coordinates) is within region. More...
 
bool ei_region_convert_point (struct ei_region *region, double *x, double *y)
 Convert the point x/y in a desktop-wide coordinate system into the corresponding point relative to the offset of the given region. More...
 
double ei_region_get_physical_scale (struct ei_region *region)
 Return the physical scale for this region. More...
 
struct ei_keymapei_device_keyboard_get_keymap (struct ei_device *device)
 Return the keymap for this device or NULL. More...
 
struct ei_deviceei_keymap_get_context (struct ei_keymap *keymap)
 Return the struct ei_device this keymap is associated with. More...
 
struct eiei_device_get_context (struct ei_device *device)
 Return the struct EI - the client implementation context this device is associated with. More...
 
void ei_device_start_emulating (struct ei_device *device)
 Notify the EIS implementation that the given device is about to start sending events. More...
 
void ei_device_stop_emulating (struct ei_device *device)
 Notify the EIS implementation that the given device is no longer sending events. More...
 
void ei_device_frame (struct ei_device *device)
 Generate a frame event to group the current set of events into a logical hardware event. More...
 
void ei_device_pointer_motion (struct ei_device *device, double x, double y)
 Generate a relative motion event on a device with the EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_motion_absolute (struct ei_device *device, double x, double y)
 Generate an absolute motion event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE capability. More...
 
void ei_device_pointer_button (struct ei_device *device, uint32_t button, bool is_press)
 Generate a button event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll (struct ei_device *device, double x, double y)
 Generate a smooth (pixel-precise) scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_discrete (struct ei_device *device, int32_t x, int32_t y)
 Generate a discrete scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_stop (struct ei_device *device, bool stop_x, bool stop_y)
 Generate a scroll stop event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_pointer_scroll_cancel (struct ei_device *device, bool cancel_x, bool cancel_y)
 Generate a scroll cancel event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability. More...
 
void ei_device_keyboard_key (struct ei_device *device, uint32_t keycode, bool is_press)
 Generate a key event on a device with the EI_DEVICE_CAP_KEYBOARD capability. More...
 
struct ei_touch * ei_device_touch_new (struct ei_device *device)
 Initiate a new touch on a device with the EI_DEVICE_CAP_TOUCH capability. More...
 
void ei_touch_down (struct ei_touch *touch, double x, double y)
 This function can only be called once on an ei_touch object. More...
 
void ei_touch_motion (struct ei_touch *touch, double x, double y)
 Move this touch to the new coordinates. More...
 
void ei_touch_up (struct ei_touch *touch)
 Release this touch. More...
 
struct ei_touch * ei_touch_ref (struct ei_touch *touch)
 Increase the refcount of this struct by one. More...
 
struct ei_touch * ei_touch_unref (struct ei_touch *touch)
 Decrease the refcount of this struct by one. More...
 
void ei_touch_set_user_data (struct ei_touch *touch, void *user_data)
 Return the custom data pointer for this context. More...
 
void * ei_touch_get_user_data (struct ei_touch *touch)
 Set a custom data pointer for this context. More...
 
struct ei_deviceei_touch_get_device (struct ei_touch *touch)
 
struct ei_seatei_event_get_seat (struct ei_event *event)
 Return the seat from this event. More...
 
const char * ei_event_property_get_name (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the property name that has changed. More...
 
const char * ei_event_property_get_value (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the new property value (at the time of the event). More...
 
uint32_t ei_event_property_get_permissions (struct ei_event *event)
 For an event of type EI_EVENT_PROPERTY, get the permissions of the property (at the time of the event). More...
 
double ei_event_pointer_get_dx (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION return the relative x movement in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_dy (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION return the relative y movement in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_absolute_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the x position in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_absolute_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the y position in logical pixels or mm, depending on the device type. More...
 
uint32_t ei_event_pointer_get_button (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_BUTTON return the button code as defined in linux/input-event-codes.h. More...
 
bool ei_event_pointer_get_button_is_press (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_BUTTON return true if the event is a button press, false for a release. More...
 
double ei_event_pointer_get_scroll_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL return the x scroll distance in logical pixels or mm, depending on the device type. More...
 
double ei_event_pointer_get_scroll_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL return the y scroll distance in logical pixels or mm, depending on the device type. More...
 
bool ei_event_pointer_get_scroll_stop_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_CANCEL return whether the x axis has cancelled scrolling. More...
 
bool ei_event_pointer_get_scroll_stop_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_STOP return whether the y axis has stopped scrolling. More...
 
int32_t ei_event_pointer_get_scroll_discrete_x (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the x scroll distance in fractions or multiples of 120. More...
 
int32_t ei_event_pointer_get_scroll_discrete_y (struct ei_event *event)
 For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the y scroll distance in fractions or multiples of 120. More...
 
uint32_t ei_event_keyboard_get_key (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_KEY return the key code (as defined in include/linux/input-event-codes.h). More...
 
bool ei_event_keyboard_get_key_is_press (struct ei_event *event)
 For an event of type EI_EVENT_KEYBOARD_KEY return true if the event is a key down, false for a release. More...
 
uint32_t ei_event_touch_get_id (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, EI_EVENT_TOUCH_MOTION, or EI_EVENT_TOUCH_UP, return the tracking ID of the touch. More...
 
double ei_event_touch_get_x (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the x coordinate of the touch in logical pixels or mm, depending on the device type. More...
 
double ei_event_touch_get_y (struct ei_event *event)
 For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the y coordinate of the touch in logical pixels or mm, depending on the device type. More...
 

Detailed Description

libei is the client-side module.

This API should be used by processes that need to emulate devices.

libei clients come in "sender" and "receiver" modes, depending on whether the client sends or receives events. A libeis context however may accept both sender and receiver clients, the EIS implementation works as corresponding receiver or sender for this client. It is up to the implementation to disconnect clients that it does not want to allow. See eis_client_is_sender() for details.

Typedef Documentation

◆ ei_log_handler

typedef void(* ei_log_handler) (struct ei *ei, enum ei_log_priority priority, const char *file, int lineno, const char *func, const char *message, bool is_continuation)

The log handler for library logging.

This handler is only called for messages with a log level equal or greater than than the one set in ei_log_set_priority().

Parameters
eiThe EI context
priorityThe log priority
fileThe filename where this log message was triggered
linenoThe line number in file where this log message was triggered
funcThe function name where this log message was triggered
messageThe log message as a null-terminated string
is_continuationThe message is a continuation of the previous message. The caller should skip any per-line-based prefixes.

Enumeration Type Documentation

◆ ei_device_capability

The set of supported capabilities.

A device may have zero or more capabilities, a device with perceived zero capabilities is typically a device with capabilities unsupported by the client.

Capabilities are initialized by the EIS implementation but the client may further reduce the requested capabilities, see ei_seat_confirm_capability(). For example, a client may bind to a seat with the pointer and keyboard capability but only the former is permitted by the EIS implementation. Keyboard events sent through such a device will be treated as client bug and discarded.

See ei_device_has_capability().

Enumerator
EI_DEVICE_CAP_POINTER 
EI_DEVICE_CAP_POINTER_ABSOLUTE 
EI_DEVICE_CAP_KEYBOARD 
EI_DEVICE_CAP_TOUCH 

◆ ei_device_type

The device type determines what the device represents.

If the device type is EI_DEVICE_TYPE_VIRTUAL, the device is a virtual device representing input as applied on the EIS implementation's screen. A relative virtual device generates input events in logical pixels, an absolute virtual device generates input events in logical pixels on one of the device's regions. Virtual devices do not have a size.

If the device type is EI_DEVICE_TYPE_PHYSICAL, the device is a representation of a physical device as if connected to the EIS implementation's host computer. A relative physical device generates input events in mm, an absolute physical device generates input events in mm within the device's specified physical size. Physical devices do not have regions.

See also
eis_device_get_width
eis_device_get_height
Enumerator
EI_DEVICE_TYPE_VIRTUAL 
EI_DEVICE_TYPE_PHYSICAL 

◆ ei_event_type

Enumerator
EI_EVENT_CONNECT 

The server has approved the connection to this client.

Where the server does not approve the connection, EI_EVENT_DISCONNECT is sent instead.

This event is only sent once after the initial connection request.

EI_EVENT_DISCONNECT 

The server has disconnected this client - all resources left to reference this server are now obsolete.

Once this event has been received, the struct EI - the client implementation and all its associated resources should be released.

This event may occur at any time after the connection has been made and is the last event to be received by this ei instance.

libei guarantees that a EI_EVENT_DISCONNECT is provided to the caller even where the server does not send one.

EI_EVENT_PROPERTY 

The server has added, removed, or changed a property.

This event is not generated for properties without the EI_PROPERTY_PERM_READ set.

EI_EVENT_SEAT_ADDED 

The server has added a seat available to this client.

libei guarantees that any seat added has a corresponding EI_EVENT_SEAT_REMOVED event before EI_EVENT_DISCONNECT. libei guarantees that any device in this seat generates a EI_EVENT_DEVICE_REMOVED event before the EI_EVENT_SEAT_REMOVED event.

EI_EVENT_SEAT_REMOVED 

The server has removed a seat previously available to this client.

The caller should release the struct ei_seat and all its associated resources. No devices will be added to this seat anymore.

libei guarantees that any device in this seat generates a EI_EVENT_DEVICE_REMOVED event before the EI_EVENT_SEAT_REMOVED event.

EI_EVENT_DEVICE_ADDED 

The server has added a device for this client.

The capabilities of the device may be a subset of the seat capabilities - it is up to the client to verify the minimum required capabilities are indeed set.

libei guarantees that any device added has a corresponding EI_EVENT_DEVICE_REMOVED event before EI_EVENT_DISCONNECT.

EI_EVENT_DEVICE_REMOVED 

The server has removed a device belonging to this client.

The caller should release the struct ei_device and all its associated resources. Any events sent through a removed device are discarded.

When this event is received, the device is already removed. A caller does not need to call ei_device_close() event on this device.

EI_EVENT_DEVICE_PAUSED 

Any events sent from this device will be discarded until the next resume.

The state of a device is not expected to change between pause/resume - for any significant state changes the server is expected to remove the device instead.

EI_EVENT_DEVICE_RESUMED 

The client may send events.

EI_EVENT_KEYBOARD_MODIFIERS 

The server has changed the modifier state on the device's keymap.

See ei_event_keyboard_get_xkb_mods_depressed(), ei_event_keyboard_get_xkb_mods_latched(), ei_event_keyboard_get_xkb_mods_locked(), and ei_event_keyboard_get_xkb_group().

This event is sent in response to an external modifier state change. Where the client triggers a modifier state change in response to ei_device_keyboard_key(), no such event is sent.

This event may arrive while a device is paused.

EI_EVENT_FRAME 

"Hardware" frame event.

This event must be sent by the server and notifies the client that the previous set of events belong to the same logical hardware event.

These events are only generated on a receiver ei context.

This event is most commonly used to implement multitouch (multiple touches may update within the same hardware scanout cycle).

EI_EVENT_DEVICE_START_EMULATING 

The server is about to send events for a device.

This event should be used by the client to clear the logical state of the emulated devices and/or provide UI to the user.

These events are only generated on a receiver ei context.

Note that a server start multiple emulating sequences simultaneously, depending on the devices available. For example, in a synergy-like situation, the server may start sending pointer and keyboard once the remote device logically entered the screen.

EI_EVENT_DEVICE_STOP_EMULATING 
EI_EVENT_POINTER_MOTION 
EI_EVENT_POINTER_MOTION_ABSOLUTE 
EI_EVENT_POINTER_BUTTON 
EI_EVENT_POINTER_SCROLL 
EI_EVENT_POINTER_SCROLL_STOP 
EI_EVENT_POINTER_SCROLL_CANCEL 
EI_EVENT_POINTER_SCROLL_DISCRETE 
EI_EVENT_KEYBOARD_KEY 
EI_EVENT_TOUCH_DOWN 
EI_EVENT_TOUCH_UP 
EI_EVENT_TOUCH_MOTION 

◆ ei_keymap_type

The set of supported keymap types for a struct ei_keymap.

Enumerator
EI_KEYMAP_TYPE_XKB 

A libxkbcommon-compatible XKB keymap.

◆ ei_log_priority

Enumerator
EI_LOG_PRIORITY_DEBUG 
EI_LOG_PRIORITY_INFO 
EI_LOG_PRIORITY_WARNING 
EI_LOG_PRIORITY_ERROR 

◆ ei_property_permission

A set of masks for operations permitted on properties.

Note that property permissions only affect the libei client, the server has full access to the properties at any time.

Enumerator
EI_PROPERTY_PERM_NONE 
EI_PROPERTY_PERM_READ 
EI_PROPERTY_PERM_WRITE 
EI_PROPERTY_PERM_DELETE 
EI_PROPERTY_PERM_ALL 

Function Documentation

◆ __attribute__()

__attribute__ ( (sentinel)  )

Same as ei_seat_bind_capability() but takes multiple capabilities, terminated by NULL.

Same as ei_seat_unbind_capability() but takes multiple capabilities, terminated by NULL.

◆ ei_configure_name()

void ei_configure_name ( struct ei ei,
const char *  name 
)

Set the name for this client.

This is a suggestion to the server only and may not be honored.

The client name may be used for display to the user, for example in an authorization dialog that requires the user to approve a connection to the EIS implementation.

This function must be called immediately after ei_new() and before setting up a backend with ei_setup_backend_socket() or ei_setup_backend_fd().

◆ ei_device_close()

void ei_device_close ( struct ei_device device)

Notify the server that the client is no longer interested in this device.

Due to the asynchronous nature of the client-server interaction, events for this device may still be in transit. The server will send an EI_EVENT_DEVICE_REMOVED event for this device. After that event, device is considered removed by the server.

A client can assume that an EI_EVENT_DEVICE_REMOVED event is sent for any device for which ei_device_close() was called before the EI_EVENT_DISCONNECT event. Where a client gets disconnected libei will emulate that event.

This does not release any resources associated with this device, use ei_device_unref() for any references held by the client.

◆ ei_device_frame()

void ei_device_frame ( struct ei_device device)

Generate a frame event to group the current set of events into a logical hardware event.

This function must be called after any other event has been generated.

◆ ei_device_get_context()

struct ei* ei_device_get_context ( struct ei_device device)

Return the struct EI - the client implementation context this device is associated with.

◆ ei_device_get_keymap()

struct ei_keymap* ei_device_get_keymap ( struct ei_device device)

◆ ei_device_get_name()

const char* ei_device_get_name ( struct ei_device device)
Returns
the name of the device (if any) or NULL

◆ ei_device_get_region()

struct ei_region* ei_device_get_region ( struct ei_device device,
size_t  index 
)

Obtain a region from a device of type EI_DEVICE_TYPE_VIRTUAL.

The number of regions is constant for a device and the indices of any region remains the same for the lifetime of the device.

Regions are shared between all capabilities. Where two capabilities need different regions, the EIS implementation must create multiple devices with individual capabilities and regions. For example, two touchscreens that are mapped to two screens would typically show up as two separate devices with one region each.

This function returns the given region or NULL if the index is larger than the number of regions available.

This does not increase the refcount of the region. Use ei_region_ref() to keep a reference beyond the immediate scope.

Devices of type EI_DEVICE_TYPE_PHYSICAL do not have regions.

◆ ei_device_get_seat()

struct ei_seat* ei_device_get_seat ( struct ei_device device)

◆ ei_device_get_type()

enum ei_device_type ei_device_get_type ( struct ei_device device)

The device type of the device is determined by the type of the ei context.

If the client context was created with ei_new_sender(), the device type defaults to EI_DEVICE_TYPE_VIRTUAL. If the client context was created with ei_new_receiver(), the device type defaults to EI_DEVICE_TYPE_PHYSICAL.

◆ ei_device_get_user_data()

void* ei_device_get_user_data ( struct ei_device device)

Return the custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_device_get_user_data() to change the user data.

◆ ei_device_has_capability()

bool ei_device_has_capability ( struct ei_device device,
enum ei_device_capability  cap 
)

Return true if the device has the requested capability.

Device capabilities are constant.

◆ ei_device_keyboard_get_keymap()

struct ei_keymap* ei_device_keyboard_get_keymap ( struct ei_device device)

Return the keymap for this device or NULL.

The keymap is constant for the lifetime of the device and applies to this device individually.

If this function returns NULL, this device does not have an individual keymap assigned. What keymap applies to the device in this case is a server implementation detail.

This does not increase the refcount of the keymap. Use ei_keymap_ref() to keep a reference beyond the immediate scope.

◆ ei_device_keyboard_key()

void ei_device_keyboard_key ( struct ei_device device,
uint32_t  keycode,
bool  is_press 
)

Generate a key event on a device with the EI_DEVICE_CAP_KEYBOARD capability.

Keys use the evdev scan codes as defined in linux/input-event-codes.h.

Note that this is a keymap-independent key code, equivalent to the scancode a physical keyboard would produce. To generate a specific key symbol, a client must look at the keymap returned by ei_device_get_keymap() and generate the appropriate keycodes.

Parameters
deviceThe EI device
keycodeThe key code
is_presstrue for key down, false for key up

◆ ei_device_pointer_button()

void ei_device_pointer_button ( struct ei_device device,
uint32_t  button,
bool  is_press 
)

Generate a button event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability.

Button codes must match the defines in linux/input-event-codes.h

Parameters
deviceThe EI device
buttonThe button code
is_presstrue for button press, false for button release

◆ ei_device_pointer_motion()

void ei_device_pointer_motion ( struct ei_device device,
double  x,
double  y 
)

Generate a relative motion event on a device with the EI_DEVICE_CAP_POINTER capability.

Parameters
deviceThe EI device
xThe x movement in logical pixels
yThe y movement in logical pixels

◆ ei_device_pointer_motion_absolute()

void ei_device_pointer_motion_absolute ( struct ei_device device,
double  x,
double  y 
)

Generate an absolute motion event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE capability.

The x/y coordinate must be within the device's regions or the event is silently discarded.

Parameters
deviceThe EI device
xThe x position in logical pixels
yThe y position in logical pixels

◆ ei_device_pointer_scroll()

void ei_device_pointer_scroll ( struct ei_device device,
double  x,
double  y 
)

Generate a smooth (pixel-precise) scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability.

Note
The server is responsible for emulating discrete scrolling based on the pixel value, do not call ei_device_pointer_scroll_discrete() for the same input event.
Parameters
deviceThe EI device
xThe x scroll distance in logical pixels
yThe y scroll distance in logical pixels
See also
ei_device_pointer_scroll_discrete

◆ ei_device_pointer_scroll_cancel()

void ei_device_pointer_scroll_cancel ( struct ei_device device,
bool  cancel_x,
bool  cancel_y 
)

Generate a scroll cancel event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability.

A scroll cancel event notifies the server that a scroll motion previously triggered with ei_device_pointer_scroll() or ei_device_pointer_scroll_discrete() has ceased and no further events should be sent.

This event indicates that the interaction has stopped to the point where further (server-emulated) scroll events from this device are wrong.

Use ei_device_pointer_scroll_stop() to signal that the interaction has stopped but a server may emulate further scroll events.

Calling ei_device_pointer_scroll_cancel() after ei_device_pointer_scroll_stop() without any of ei_device_pointer_scroll() or ei_device_pointer_scroll_discrete() in between iis permitted.

libei keeps track of the scroll axis and filters duplicate calls to ei_device_pointer_scroll_cancel() for the same axis. A nonzero scroll or scroll-discrete value is required for the given axis to re-start scrolling for that axis.

◆ ei_device_pointer_scroll_discrete()

void ei_device_pointer_scroll_discrete ( struct ei_device device,
int32_t  x,
int32_t  y 
)

Generate a discrete scroll event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability.

A discrete scroll event is based logical scroll units (equivalent to one mouse wheel click). The value for one scroll unit is 120, a fraction or multiple thereof represents a fraction or multiple of a wheel click.

Note
The server is responsible for emulating pixel-based scrolling based on the discrete value, do not call ei_device_pointer_scroll() for the same input event.
Parameters
deviceThe EI device
xThe x scroll distance in fractions or multiples of 120
yThe y scroll distance in fractions or multiples of 120
See also
ei_device_pointer_scroll

◆ ei_device_pointer_scroll_stop()

void ei_device_pointer_scroll_stop ( struct ei_device device,
bool  stop_x,
bool  stop_y 
)

Generate a scroll stop event on a device with the EI_DEVICE_CAP_POINTER_ABSOLUTE or EI_DEVICE_CAP_POINTER capability.

A scroll stop event notifies the server that the interaction causing a scroll motion previously triggered with ei_device_pointer_scroll() or ei_device_pointer_scroll_discrete() has stopped. For example, if all fingers are lifted off a touchpad, two-finger scrolling has logically stopped.

The server may use this information to e.g. start kinetic scrolling previously based on the previous finger speed.

Use ei_device_pointer_scroll_cancel() to signal that the scroll motion has completely stopped.

Calling ei_device_pointer_scroll_stop() after ei_device_pointer_scroll_cancel() without any of ei_device_pointer_scroll() or ei_device_pointer_scroll_discrete() in between indicates a client logic bug.

libei keeps track of the scroll axis and filters duplicate calls to ei_device_pointer_scroll_stop() for the same axis. A nonzero scroll or scroll-discrete value is required for the given axis to re-start scrolling for that axis.

◆ ei_device_ref()

struct ei_device* ei_device_ref ( struct ei_device device)

Increase the refcount of this struct by one.

Use ei_device_unref() to decrease the refcount.

Returns
the argument passed into the function

◆ ei_device_set_user_data()

void ei_device_set_user_data ( struct ei_device device,
void *  user_data 
)

Set a custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_device_get_user_data() to retrieve a previously set user data.

◆ ei_device_start_emulating()

void ei_device_start_emulating ( struct ei_device device)

Notify the EIS implementation that the given device is about to start sending events.

This should be seen more as a transactional boundary than a time-based boundary. The primary use-case for this is to allow for setup on the EIS implementation side and/or UI updates to indicate that a device is sending events now.

There is no actual requirement that events start immediately once emulation starts and there is no requirement that a client calls ei_device_stop_emulating() after the most recent events.

For example, in a synergy-like use-case the client would call ei_device_start_emulating() once the pointer moves into the the screen and ei_device_stop_emulating() once the pointer moves out of the screen.

Sending events before ei_device_start_emulating() or after ei_device_stop_emulating() is a client bug.

◆ ei_device_stop_emulating()

void ei_device_stop_emulating ( struct ei_device device)

Notify the EIS implementation that the given device is no longer sending events.

See ei_device_start_emulating() for details.

◆ ei_device_touch_new()

struct ei_touch* ei_device_touch_new ( struct ei_device device)

Initiate a new touch on a device with the EI_DEVICE_CAP_TOUCH capability.

This touch does not immediately send events, use ei_touch_down(), ei_touch_motion(), and ei_touch_up().

The returned touch has a refcount of at least 1, use ei_touch_unref() to release resources associated with this touch

◆ ei_device_unref()

struct ei_device* ei_device_unref ( struct ei_device device)

Decrease the refcount of this struct by one.

When the refcount reaches zero, the context disconnects from the server and all allocated resources are released.

Returns
always NULL

◆ ei_dispatch()

void ei_dispatch ( struct ei ei)

Main event dispatching function.

Reads events of the file descriptors and processes them internally. Use libei_get_event() to retrieve the events.

Dispatching does not necessarily queue events. This function should be called immediately once data is available on the file descriptor returned by libei_get_fd().

◆ ei_event_get_device()

struct ei_device* ei_event_get_device ( struct ei_event event)

Return the device from this event.

For events of type EI_EVENT_CONNECT and EI_EVENT_DISCONNECT, this function returns NULL.

This does not increase the refcount of the device. Use eis_device_ref() to keep a reference beyond the immediate scope.

◆ ei_event_get_seat()

struct ei_seat* ei_event_get_seat ( struct ei_event event)

Return the seat from this event.

For events of type EI_EVENT_CONNECT and EI_EVENT_DISCONNECT, this function returns NULL.

This does not increase the refcount of the seat. Use eis_seat_ref() to keep a reference beyond the immediate scope.

◆ ei_event_get_time()

uint64_t ei_event_get_time ( struct ei_event event)
Returns
the event time in microseconds

◆ ei_event_get_type()

enum ei_event_type ei_event_get_type ( struct ei_event event)
Returns
the type of this event

◆ ei_event_keyboard_get_key()

uint32_t ei_event_keyboard_get_key ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_KEY return the key code (as defined in include/linux/input-event-codes.h).

◆ ei_event_keyboard_get_key_is_press()

bool ei_event_keyboard_get_key_is_press ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_KEY return true if the event is a key down, false for a release.

◆ ei_event_keyboard_get_xkb_group()

uint32_t ei_event_keyboard_get_xkb_group ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the logical group state.

See ei_device_get_keymap() for the corresponding keymap.

◆ ei_event_keyboard_get_xkb_mods_depressed()

uint32_t ei_event_keyboard_get_xkb_mods_depressed ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically pressed-down modifiers.

See ei_device_get_keymap() for the corresponding keymap.

◆ ei_event_keyboard_get_xkb_mods_latched()

uint32_t ei_event_keyboard_get_xkb_mods_latched ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically latched modifiers.

See ei_device_get_keymap() for the corresponding keymap.

◆ ei_event_keyboard_get_xkb_mods_locked()

uint32_t ei_event_keyboard_get_xkb_mods_locked ( struct ei_event event)

For an event of type EI_EVENT_KEYBOARD_MODIFIERS, get the mask of currently logically locked modifiers.

See ei_device_get_keymap() for the corresponding keymap.

◆ ei_event_pointer_get_absolute_x()

double ei_event_pointer_get_absolute_x ( struct ei_event event)

For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the x position in logical pixels or mm, depending on the device type.

◆ ei_event_pointer_get_absolute_y()

double ei_event_pointer_get_absolute_y ( struct ei_event event)

For an event of type EI_EVENT_POINTER_MOTION_ABSOLUTE return the y position in logical pixels or mm, depending on the device type.

◆ ei_event_pointer_get_button()

uint32_t ei_event_pointer_get_button ( struct ei_event event)

For an event of type EI_EVENT_POINTER_BUTTON return the button code as defined in linux/input-event-codes.h.

◆ ei_event_pointer_get_button_is_press()

bool ei_event_pointer_get_button_is_press ( struct ei_event event)

For an event of type EI_EVENT_POINTER_BUTTON return true if the event is a button press, false for a release.

◆ ei_event_pointer_get_dx()

double ei_event_pointer_get_dx ( struct ei_event event)

For an event of type EI_EVENT_POINTER_MOTION return the relative x movement in logical pixels or mm, depending on the device type.

◆ ei_event_pointer_get_dy()

double ei_event_pointer_get_dy ( struct ei_event event)

For an event of type EI_EVENT_POINTER_MOTION return the relative y movement in logical pixels or mm, depending on the device type.

◆ ei_event_pointer_get_scroll_discrete_x()

int32_t ei_event_pointer_get_scroll_discrete_x ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the x scroll distance in fractions or multiples of 120.

◆ ei_event_pointer_get_scroll_discrete_y()

int32_t ei_event_pointer_get_scroll_discrete_y ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL_DISCRETE return the y scroll distance in fractions or multiples of 120.

◆ ei_event_pointer_get_scroll_stop_x()

bool ei_event_pointer_get_scroll_stop_x ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL_CANCEL return whether the x axis has cancelled scrolling.

◆ ei_event_pointer_get_scroll_stop_y()

bool ei_event_pointer_get_scroll_stop_y ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL_STOP return whether the y axis has stopped scrolling.

◆ ei_event_pointer_get_scroll_x()

double ei_event_pointer_get_scroll_x ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL return the x scroll distance in logical pixels or mm, depending on the device type.

◆ ei_event_pointer_get_scroll_y()

double ei_event_pointer_get_scroll_y ( struct ei_event event)

For an event of type EI_EVENT_POINTER_SCROLL return the y scroll distance in logical pixels or mm, depending on the device type.

◆ ei_event_property_get_name()

const char* ei_event_property_get_name ( struct ei_event event)

For an event of type EI_EVENT_PROPERTY, get the property name that has changed.

◆ ei_event_property_get_permissions()

uint32_t ei_event_property_get_permissions ( struct ei_event event)

For an event of type EI_EVENT_PROPERTY, get the permissions of the property (at the time of the event).

Note that the property permissions as seen in the event and the property permissiosn on the ei context as returned by ei_property_get_permissions() may differ. The latter always reflects the current state of the property while the event contains the permissions of the property at the time of the event.

◆ ei_event_property_get_value()

const char* ei_event_property_get_value ( struct ei_event event)

For an event of type EI_EVENT_PROPERTY, get the new property value (at the time of the event).

A property value of NULL indicates the property has been deleted.

Note that the property value as seen in the event and the property value on the ei context as returned by ei_property_get() may differ. The latter always reflects the current state of the property while the event contains the value of the property at the time of the event.

◆ ei_event_touch_get_id()

uint32_t ei_event_touch_get_id ( struct ei_event event)

For an event of type EI_EVENT_TOUCH_DOWN, EI_EVENT_TOUCH_MOTION, or EI_EVENT_TOUCH_UP, return the tracking ID of the touch.

The tracking ID is a unique identifier for a touch and is valid from touch down through to touch up but may be re-used in the future. The tracking ID is randomly assigned to a touch, a client must not expect any specific value.

◆ ei_event_touch_get_x()

double ei_event_touch_get_x ( struct ei_event event)

For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the x coordinate of the touch in logical pixels or mm, depending on the device type.

◆ ei_event_touch_get_y()

double ei_event_touch_get_y ( struct ei_event event)

For an event of type EI_EVENT_TOUCH_DOWN, or EI_EVENT_TOUCH_MOTION, return the y coordinate of the touch in logical pixels or mm, depending on the device type.

◆ ei_event_unref()

struct ei_event* ei_event_unref ( struct ei_event event)

Release resources associated with this event.

This function always returns NULL.

The caller cannot increase the refcount of an event. Events should be considered transient data and not be held longer than required. ei_event_unref() is provided for consistency (as opposed to, say, ei_event_free()).

◆ ei_get_event()

struct ei_event* ei_get_event ( struct ei ei)

Return the next event from the event queue, removing it from the queue.

The returned object must be released by the caller with ei_event_unref()

◆ ei_get_fd()

int ei_get_fd ( struct ei ei)

libei keeps a single file descriptor for all events.

This fd should be monitored for events by the caller's mainloop, e.g. using select(). When events are available on this fd, call libei_dispatch() immediately to process.

◆ ei_get_user_data()

void* ei_get_user_data ( struct ei ei)

Return the custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_set_user_data() to change the user data.

◆ ei_is_sender()

bool ei_is_sender ( struct ei ei)

◆ ei_keymap_get_context()

struct ei_device* ei_keymap_get_context ( struct ei_keymap keymap)

Return the struct ei_device this keymap is associated with.

◆ ei_keymap_get_device()

struct ei_device* ei_keymap_get_device ( struct ei_keymap keymap)

Return the device this keymap belongs to, or NULL if it has not yet been assigned to a device.

After processing and if the server changed the keymap or set the keymap to NULL, this keymap may no longer be in use by the device and future calls to this function return NULL.

◆ ei_keymap_get_fd()

int ei_keymap_get_fd ( struct ei_keymap keymap)

Return a memmap-able file descriptor pointing to the keymap used by the device.

The keymap is constant for the lifetime of the device and assigned to this device individually.

◆ ei_keymap_get_size()

size_t ei_keymap_get_size ( struct ei_keymap keymap)
Returns
the size of the keymap in bytes

◆ ei_keymap_get_type()

enum ei_keymap_type ei_keymap_get_type ( struct ei_keymap keymap)

Returns the type for this keymap.

The type specifies how to interpret the data at the file descriptor returned by ei_keymap_get_fd().

◆ ei_keymap_get_user_data()

void* ei_keymap_get_user_data ( struct ei_keymap keymap)

◆ ei_keymap_ref()

struct ei_keymap* ei_keymap_ref ( struct ei_keymap keymap)

Increase the refcount of this struct by one.

Use ei_keymap_unref() to decrease the refcount.

Returns
the argument passed into the function

◆ ei_keymap_set_user_data()

void ei_keymap_set_user_data ( struct ei_keymap keymap,
void *  user_data 
)

◆ ei_keymap_unref()

struct ei_keymap* ei_keymap_unref ( struct ei_keymap keymap)

Decrease the refcount of this struct by one.

When the refcount reaches zero, the context disconnects from the server and all allocated resources are released.

Returns
always NULL

◆ ei_log_get_priority()

enum ei_log_priority ei_log_get_priority ( const struct ei ei)

◆ ei_log_set_handler()

void ei_log_set_handler ( struct ei ei,
ei_log_handler  log_handler 
)

Change the log handler for this context.

If the log handler is NULL, the built-in default log function is used.

Parameters
eiThe EI context
log_handlerThe log handler or NULL to use the default log handler.

◆ ei_log_set_priority()

void ei_log_set_priority ( struct ei ei,
enum ei_log_priority  priority 
)

◆ ei_new()

struct ei* ei_new ( void *  user_data)

This is an alias for ei_new_sender.

◆ ei_new_receiver()

struct ei* ei_new_receiver ( void *  user_data)

Create a new receiver ei context.

The context is refcounted and must be released with ei_unref().

A receiver ei context receives events from the EIS implementation but cannot send events.

A context supports exactly one backend, set up with one of ei_setup_backend_socket() or ei_setup_backend_fd().

Parameters
user_dataAn opaque pointer to be returned with ei_get_user_data()
See also
ei_set_user_data
ei_get_user_data
ei_setup_backend_fd
ei_setup_backend_socket

◆ ei_new_sender()

struct ei* ei_new_sender ( void *  user_data)

Create a new sender ei context.

The context is refcounted and must be released with ei_unref().

A sender ei context sends events to the EIS implementation but cannot receive events.

A context supports exactly one backend, set up with one of ei_setup_backend_socket() or ei_setup_backend_fd().

Parameters
user_dataAn opaque pointer to be returned with ei_get_user_data()
See also
ei_set_user_data
ei_get_user_data
ei_setup_backend_fd
ei_setup_backend_socket

◆ ei_peek_event()

struct ei_event* ei_peek_event ( struct ei ei)

Returns the next event in the internal event queue (or NULL) without removing that event from the queue; the next call to ei_get_event() will return that same event.

This call is useful for checking whether there is an event and/or what type of event it is.

Repeated calls to ei_peek_event() return the same event.

The returned event is refcounted, use ei_event_unref() to drop the reference.

A caller must not call ei_get_event() while holding a ref to an event returned by ei_peek_event(). Doing so is undefined behavior.

◆ ei_property_get()

const char* ei_property_get ( struct ei ei,
const char *  property 
)

Return the value of the given property or NULL if the property is not set or does not have the EI_PROPERTY_PERM_READ permission.

◆ ei_property_get_permissions()

uint32_t ei_property_get_permissions ( struct ei ei,
const char *  property 
)

Return the permissions mask for the given property.

If the property does not exist or does not have the EI_PROPERTY_PERM_READ permission, this function returns zero.

◆ ei_property_set()

int ei_property_set ( struct ei ei,
const char *  property,
const char *  value 
)

See ei_property_set_with_permissions(), but the permissions are left as-is.

If the property does not exist, it is created with permissions EI_PROPERTY_PERM_ALL.

◆ ei_property_set_with_permissions()

int ei_property_set_with_permissions ( struct ei ei,
const char *  property,
const char *  value,
uint32_t  permission 
)

Change, create or delete a property.

  • If the property does not yet exist, it is created with the given ei_property_permission.
  • If the property exists and value is not NULL and the EI_PROPERTY_PERM_WRITE permission is set on the property, the value is changed to the new value and the property's permissions are updated to the given permission.
  • If the property exists and value is NULL and the EI_PROPERTY_PERM_WRITE and EI_PROPERTY_PERM_DELETE permission is set on the property, the property is deleted.

Note that property permissions only apply to the libei client, they do not apply to the EIS server which can read, modify and delete any property regardless of permissions.

Permissions can only be reduced, not increased and the permissions applied to the property are always the binary AND of permissions and the existing permissions for this property (if any).

Returns
0 on success or a negative errno on failure
Return values
-EACCESSThe client does not have sufficient permissions for this operation
-EPERMThe permissions mask is too loose

◆ ei_ref()

struct ei* ei_ref ( struct ei ei)

Increase the refcount of this struct by one.

Use ei_unref() to decrease the refcount.

Returns
the argument passed into the function

◆ ei_region_contains()

bool ei_region_contains ( struct ei_region region,
double  x,
double  y 
)

Return true if the point x/y (in desktop-wide coordinates) is within region.

◆ ei_region_convert_point()

bool ei_region_convert_point ( struct ei_region region,
double *  x,
double *  y 
)

Convert the point x/y in a desktop-wide coordinate system into the corresponding point relative to the offset of the given region.

If the point is inside the region, this function returns true and x and y are set to the points with the region offset subtracted. If the point is outside the region, this function returns false and x and y are left unmodified.

◆ ei_region_get_height()

uint32_t ei_region_get_height ( struct ei_region region)

◆ ei_region_get_physical_scale()

double ei_region_get_physical_scale ( struct ei_region region)

Return the physical scale for this region.

The default scale is 1.0.

The regions' coordinate space is in logical pixels in the EIS range. The logical pixels may or may not match the physical pixels on the output range but the mapping from logical pixels to physical pixels is performed by the EIS implementation.

In some use-cases though, relative data from a remote input source needs to be converted by the libei client into an absolute movement on an EIS region. In that case, the physical scale provides the factor to multiply the relative logical input to provide the expected physical relative movement.

For example consider the following dual-monitor setup comprising a 2k and a 4k monitor of the same physical size: The physical layout of the monitors appears like this:

2k 4k
+-------------++-------------+
| || |
| a b || c d |
| || |
+-------------++-------------+

The physical distance ab is the same as the physical distance cd. Where the EIS implementation supports high-dpi screens, the logical distance (in pixels) are identical too.

Where the EIS implementation does not support high-dpi screens, the logical layout of these two monitors appears like this:

2k 4k
+-------------++--------------------------+
| || |
| a b || |
| || |
+-------------+| c d |
| |
| |
| |
+--------------------------+

While the two physical distances ab and cd are still identical, the logical distance cd (in pixels) is twice that of ab. Where a libei client receives relative deltas from an input source and converts that relative input into an absolute position on the screen, it needs to take this into account.

For example, if a remote input source moves by relative 100 logical pixels, the libei client would convert this as a + 100 = b on the region for the 2k screen and send the absolute events to logically change the position from a to b. If the same remote input source moves by relative 100 logical pixels, the libei client would convert this as c + 100 * scale = d on the region for the 4k screen to logically change the position from c to d. While the pixel movement differs, the physical movement as seen by the user is thus identical.

A second possible use-case for the physical scale is to match pixels from one region to their respective counterpart on a different region. For example, if the bottom-right corner of the 2k screen in the illustration above has a coordinate of (x, y), the neighbouring pixel on the physical 4k screen is (0, y * scale).

◆ ei_region_get_user_data()

void* ei_region_get_user_data ( struct ei_region region)

◆ ei_region_get_width()

uint32_t ei_region_get_width ( struct ei_region region)

◆ ei_region_get_x()

uint32_t ei_region_get_x ( struct ei_region region)

◆ ei_region_get_y()

uint32_t ei_region_get_y ( struct ei_region region)

◆ ei_region_ref()

struct ei_region* ei_region_ref ( struct ei_region region)

◆ ei_region_set_user_data()

void ei_region_set_user_data ( struct ei_region region,
void *  user_data 
)

◆ ei_region_unref()

struct ei_region* ei_region_unref ( struct ei_region region)

◆ ei_seat_bind_capability()

void ei_seat_bind_capability ( struct ei_seat seat,
enum ei_device_capability  cap 
)

Bind this client to the given seat capability.

Once bound, the server may create devices for the requested capability and send the respective EI_EVENT_DEVICE_ADDED events. To undo, call ei_seat_unbind_capability().

Note that binding to a capability does not guarantee a device for that capability becomes available. Devices may be added and removed at any time.

It is an application bug to call this function for a capability already bound - call ei_seat_unbind_capability() first.

Calling this function for a capability that does not exist on the seat is permitted (but obviously a noop)

◆ ei_seat_get_context()

struct ei* ei_seat_get_context ( struct ei_seat seat)

Return the struct EI - the client implementation context this seat is associated with.

◆ ei_seat_get_name()

const char* ei_seat_get_name ( struct ei_seat seat)

◆ ei_seat_get_user_data()

void* ei_seat_get_user_data ( struct ei_seat seat)

Return the custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_seat_get_user_data() to change the user data.

◆ ei_seat_has_capability()

bool ei_seat_has_capability ( struct ei_seat seat,
enum ei_device_capability  cap 
)

Return true if the capabilitiy is available on this seat or false otherwise.

The return value of this function is not affected by ei_seat_confirm_capability().

◆ ei_seat_ref()

struct ei_seat* ei_seat_ref ( struct ei_seat seat)

◆ ei_seat_set_user_data()

void ei_seat_set_user_data ( struct ei_seat seat,
void *  user_data 
)

Set a custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_seat_get_user_data() to retrieve a previously set user data.

◆ ei_seat_unbind_capability()

void ei_seat_unbind_capability ( struct ei_seat seat,
enum ei_device_capability  cap 
)

Unbind a seat's capability.

This function indicates the the application is no longer interested in devices with the given capability.

If any devices with the given capability are present, libei automatically calls ei_device_close() on those devices (and thus the server will send EI_EVENT_DEVICE_REMOVED for those devices).

◆ ei_seat_unref()

struct ei_seat* ei_seat_unref ( struct ei_seat seat)

◆ ei_set_user_data()

void ei_set_user_data ( struct ei ei,
void *  user_data 
)

Set a custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_get_user_data() to retrieve a previously set user data.

◆ ei_setup_backend_fd()

int ei_setup_backend_fd ( struct ei ei,
int  fd 
)

Initialize the ei context on the given socket.

The ei context will initiate the conversation with the EIS server listening on the other end of this socket.

If the connection was successful, an event of type EI_EVENT_CONNECT or EI_EVENT_DISCONNECT will become available after a future call to ei_dispatch().

If the connection failed, use ei_unref() to release the data allocated for this context.

This function takes ownership of the file descriptor, and will close it when tearing down.

Returns
zero on success or a negative errno on failure

◆ ei_setup_backend_portal()

int ei_setup_backend_portal ( struct ei ei)

Connect to the org.freedesktop.portal.Desktop portal.

Returns
0 on success or a negative errno on failure

◆ ei_setup_backend_portal_busname()

int ei_setup_backend_portal_busname ( struct ei ei,
const char *  busname 
)

Connect to an org.freedesktop.portal.Desktop implementation on the given busname.

Outside of testing environments, there is usually no reason to use this function, use ei_setup_backend_portal() instead.

Returns
0 on success or a negative errno on failure

◆ ei_setup_backend_socket()

int ei_setup_backend_socket ( struct ei ei,
const char *  socketpath 
)

Set this ei context to use the socket backend.

The ei context will connect to the socket at the given path and initiate the conversation with the EIS server listening on that socket.

If socketpath is NULL, the value of the environment variable LIBEI_SOCKET is used. If socketpath does not start with '/', it is relative to $XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not set, this function fails.

If the connection was successful, an event of type EI_EVENT_CONNECT or EI_EVENT_DISCONNECT will become available after a future call to ei_dispatch().

If the connection failed, use ei_unref() to release the data allocated for this context.

Returns
zero on success or a negative errno on failure

◆ ei_touch_down()

void ei_touch_down ( struct ei_touch *  touch,
double  x,
double  y 
)

This function can only be called once on an ei_touch object.

Further calls to ei_touch_down() on the same object are silently ignored.

The x/y coordinate must be within the device's regions or the event is silently discarded.

Parameters
touchA newly created touch
xThe x position in logical pixels
yThe y position in logical pixels

◆ ei_touch_get_device()

struct ei_device* ei_touch_get_device ( struct ei_touch *  touch)
Returns
the device this touch originates on

◆ ei_touch_get_user_data()

void* ei_touch_get_user_data ( struct ei_touch *  touch)

Set a custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_touch_get_user_data() to retrieve a previously set user data.

◆ ei_touch_motion()

void ei_touch_motion ( struct ei_touch *  touch,
double  x,
double  y 
)

Move this touch to the new coordinates.

◆ ei_touch_ref()

struct ei_touch* ei_touch_ref ( struct ei_touch *  touch)

Increase the refcount of this struct by one.

Use ei_touch_unref() to decrease the refcount.

Returns
the argument passed into the function

◆ ei_touch_set_user_data()

void ei_touch_set_user_data ( struct ei_touch *  touch,
void *  user_data 
)

Return the custom data pointer for this context.

libei will not look at or modify the pointer. Use ei_touch_set_user_data() to change the user data.

◆ ei_touch_unref()

struct ei_touch* ei_touch_unref ( struct ei_touch *  touch)

Decrease the refcount of this struct by one.

When the refcount reaches zero, the context disconnects from the server and all allocated resources are released.

Returns
always NULL

◆ ei_touch_up()

void ei_touch_up ( struct ei_touch *  touch)

Release this touch.

After this call, the touch event becomes inert and no longer responds to either ei_touch_down(), ei_touch_motion() or ei_touch_up() and the caller should call ei_touch_unref().

◆ ei_unref()

struct ei* ei_unref ( struct ei ei)

Decrease the refcount of this struct by one.

When the refcount reaches zero, the context disconnects from the server and all allocated resources are released.

Returns
always NULL