Rename ei active/passive to sender/receiver

This is more explicit in what it actually does, making it easier to
immediately understand the code.
This commit is contained in:
Peter Hutterer 2022-03-28 15:56:44 +10:00
parent fa091d7ac4
commit f35be22d2c
17 changed files with 135 additions and 133 deletions

View file

@ -60,7 +60,7 @@ message ConfigureCapabilities {
message Connect { message Connect {
string name = 1; string name = 1;
bool is_active = 2; bool is_sender = 2;
} }
message ConnectDone { message ConnectDone {

View file

@ -68,7 +68,7 @@ struct ei {
const struct ei_proto_requests *requests; const struct ei_proto_requests *requests;
bool is_active; bool is_sender;
}; };
enum ei_seat_state { enum ei_seat_state {

View file

@ -316,7 +316,7 @@ ei_proto_send_connect(struct ei *ei)
prepare_msg(CONNECT, Connect, connect); prepare_msg(CONNECT, Connect, connect);
connect.name = ei->name; connect.name = ei->name;
connect.is_active = ei->is_active; connect.is_sender = ei->is_sender;
return ei_proto_send_msg(ei, &msg); return ei_proto_send_msg(ei, &msg);
} }

View file

@ -134,7 +134,7 @@ set_prop_type(struct ei *ei)
} }
static struct ei * static struct ei *
ei_create_context(bool is_active, void *user_data) ei_create_context(bool is_sender, void *user_data)
{ {
_unref_(ei) *ei = ei_create(NULL); _unref_(ei) *ei = ei_create(NULL);
@ -152,7 +152,7 @@ ei_create_context(bool is_active, void *user_data)
ei->user_data = user_data; ei->user_data = user_data;
ei->backend = NULL; ei->backend = NULL;
ei->is_active = is_active; ei->is_sender = is_sender;
set_prop_pid(ei); set_prop_pid(ei);
set_prop_cmdline(ei); set_prop_cmdline(ei);
@ -162,25 +162,25 @@ ei_create_context(bool is_active, void *user_data)
} }
_public_ bool _public_ bool
ei_is_active(struct ei *ei) ei_is_sender(struct ei *ei)
{ {
return ei->is_active; return ei->is_sender;
} }
_public_ struct ei * _public_ struct ei *
ei_new(void *user_data) ei_new(void *user_data)
{ {
return ei_new_active(user_data); return ei_new_sender(user_data);
} }
_public_ struct ei * _public_ struct ei *
ei_new_active(void *user_data) ei_new_sender(void *user_data)
{ {
return ei_create_context(true, user_data); return ei_create_context(true, user_data);
} }
_public_ struct ei * _public_ struct ei *
ei_new_passive(void *user_data) ei_new_receiver(void *user_data)
{ {
return ei_create_context(false, user_data); return ei_create_context(false, user_data);
} }
@ -1038,9 +1038,9 @@ static int handle_msg_disconnected(struct ei *ei) {
return -ECANCELED; return -ECANCELED;
} }
#define DISCONNECT_IF_ACTIVE_CONTEXT(ei_) do {\ #define DISCONNECT_IF_SENDER_CONTEXT(ei_) do {\
if (ei_->is_active) { \ if (ei_->is_sender) { \
log_bug_client(ei_, "Invalid event from passive EIS context. Disconnecting\n"); \ log_bug_client(ei_, "Invalid event from receiver EIS context. Disconnecting\n"); \
return -ECANCELED; \ return -ECANCELED; \
} \ } \
} while(0) } while(0)
@ -1048,7 +1048,7 @@ static int handle_msg_disconnected(struct ei *ei) {
static int static int
handle_msg_start_emulating(struct ei *ei, uint32_t deviceid) handle_msg_start_emulating(struct ei *ei, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1061,7 +1061,7 @@ handle_msg_start_emulating(struct ei *ei, uint32_t deviceid)
static int static int
handle_msg_stop_emulating(struct ei *ei, uint32_t deviceid) handle_msg_stop_emulating(struct ei *ei, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1074,7 +1074,7 @@ handle_msg_stop_emulating(struct ei *ei, uint32_t deviceid)
static int static int
handle_msg_frame(struct ei *ei, uint32_t deviceid) handle_msg_frame(struct ei *ei, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1088,7 +1088,7 @@ static int
handle_msg_pointer_rel(struct ei *ei, uint32_t deviceid, handle_msg_pointer_rel(struct ei *ei, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1102,7 +1102,7 @@ static int
handle_msg_pointer_abs(struct ei *ei, uint32_t deviceid, handle_msg_pointer_abs(struct ei *ei, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1116,7 +1116,7 @@ static int
handle_msg_pointer_button(struct ei *ei, uint32_t deviceid, handle_msg_pointer_button(struct ei *ei, uint32_t deviceid,
uint32_t button, bool state) uint32_t button, bool state)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1130,7 +1130,7 @@ static int
handle_msg_pointer_scroll(struct ei *ei, uint32_t deviceid, handle_msg_pointer_scroll(struct ei *ei, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1144,7 +1144,7 @@ static int
handle_msg_pointer_scroll_discrete(struct ei *ei, uint32_t deviceid, handle_msg_pointer_scroll_discrete(struct ei *ei, uint32_t deviceid,
int32_t x, int32_t y) int32_t x, int32_t y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1158,7 +1158,7 @@ static int
handle_msg_pointer_scroll_stop(struct ei *ei, uint32_t deviceid, handle_msg_pointer_scroll_stop(struct ei *ei, uint32_t deviceid,
bool x, bool y, bool is_cancel) bool x, bool y, bool is_cancel)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1176,7 +1176,7 @@ static int
handle_msg_keyboard_key(struct ei *ei, uint32_t deviceid, handle_msg_keyboard_key(struct ei *ei, uint32_t deviceid,
uint32_t key, bool state) uint32_t key, bool state)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1190,7 +1190,7 @@ static int
handle_msg_touch_down(struct ei *ei, uint32_t deviceid, handle_msg_touch_down(struct ei *ei, uint32_t deviceid,
uint32_t touchid, double x, double y) uint32_t touchid, double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1204,7 +1204,7 @@ static int
handle_msg_touch_motion(struct ei *ei, uint32_t deviceid, handle_msg_touch_motion(struct ei *ei, uint32_t deviceid,
uint32_t touchid, double x, double y) uint32_t touchid, double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);
@ -1217,7 +1217,7 @@ handle_msg_touch_motion(struct ei *ei, uint32_t deviceid,
static int static int
handle_msg_touch_up(struct ei *ei, uint32_t deviceid, uint32_t touchid) handle_msg_touch_up(struct ei *ei, uint32_t deviceid, uint32_t touchid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(ei); DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid); struct ei_device *device = ei_find_device(ei, deviceid);

View file

@ -38,11 +38,12 @@ extern "C" {
* libei is the client-side module. This API should be used by processes * libei is the client-side module. This API should be used by processes
* that need to emulate devices. * that need to emulate devices.
* *
* libei clients come in "active" and "passive" modes, depending on whether * libei clients come in "sender" and "receiver" modes, depending on whether
* the client sends or receives events. A libeis context however is both * the client sends or receives events. A libeis context however may accept
* active and passive at the same time, it is up to the implementation to * both sender and receiver clients, the EIS implementation works as
* disconnect clients that it does not want to allow. See * corresponding receiver or sender for this client. It is up to the
* eis_client_is_active() for details. * implementation to disconnect clients that it does not want to allow. See
* eis_client_is_sender() for details.
* *
* @{ * @{
*/ */
@ -316,7 +317,7 @@ enum ei_event_type {
* and notifies the client that the previous set of events belong to * and notifies the client that the previous set of events belong to
* the same logical hardware event. * the same logical hardware event.
* *
* These events are only generated on a passive ei context. * These events are only generated on a receiver ei context.
* *
* This event is most commonly used to implement multitouch (multiple * This event is most commonly used to implement multitouch (multiple
* touches may update within the same hardware scanout cycle). * touches may update within the same hardware scanout cycle).
@ -328,7 +329,7 @@ enum ei_event_type {
* be used by the client to clear the logical state of the emulated * be used by the client to clear the logical state of the emulated
* devices and/or provide UI to the user. * devices and/or provide UI to the user.
* *
* These events are only generated on a passive ei context. * These events are only generated on a receiver ei context.
* *
* Note that a server start multiple emulating sequences * Note that a server start multiple emulating sequences
* simultaneously, depending on the devices available. * simultaneously, depending on the devices available.
@ -339,7 +340,7 @@ enum ei_event_type {
EI_EVENT_DEVICE_START_EMULATING = 200, EI_EVENT_DEVICE_START_EMULATING = 200,
EI_EVENT_DEVICE_STOP_EMULATING, EI_EVENT_DEVICE_STOP_EMULATING,
/* These events are only generated on a passive ei context. */ /* These events are only generated on a receiver ei context. */
EI_EVENT_POINTER_MOTION = 300, EI_EVENT_POINTER_MOTION = 300,
EI_EVENT_POINTER_MOTION_ABSOLUTE, EI_EVENT_POINTER_MOTION_ABSOLUTE,
EI_EVENT_POINTER_BUTTON, EI_EVENT_POINTER_BUTTON,
@ -356,16 +357,16 @@ enum ei_event_type {
}; };
/** /**
* This is an alias for @ref ei_new_active. * This is an alias for @ref ei_new_sender.
*/ */
struct ei * struct ei *
ei_new(void *user_data); ei_new(void *user_data);
/** /**
* Create a new active ei context. The context is refcounted and must be * Create a new sender ei context. The context is refcounted and must be
* released with ei_unref(). * released with ei_unref().
* *
* An active ei context sends events to the EIS implementation but cannot * A sender ei context sends events to the EIS implementation but cannot
* receive events. * receive events.
* *
* A context supports exactly one backend, set up with one of * A context supports exactly one backend, set up with one of
@ -379,13 +380,13 @@ ei_new(void *user_data);
* @see ei_setup_backend_socket * @see ei_setup_backend_socket
*/ */
struct ei * struct ei *
ei_new_active(void *user_data); ei_new_sender(void *user_data);
/** /**
* Create a new passive ei context. The context is refcounted and must be * Create a new receiver ei context. The context is refcounted and must be
* released with ei_unref(). * released with ei_unref().
* *
* A passive ei context receives events from the EIS implementation but cannot * A receiver ei context receives events from the EIS implementation but cannot
* send events. * send events.
* *
* A context supports exactly one backend, set up with one of * A context supports exactly one backend, set up with one of
@ -399,10 +400,10 @@ ei_new_active(void *user_data);
* @see ei_setup_backend_socket * @see ei_setup_backend_socket
*/ */
struct ei * struct ei *
ei_new_passive(void *user_data); ei_new_receiver(void *user_data);
bool bool
ei_is_active(struct ei *ei); ei_is_sender(struct ei *ei);
enum ei_log_priority { enum ei_log_priority {
EI_LOG_PRIORITY_DEBUG = 10, EI_LOG_PRIORITY_DEBUG = 10,
@ -936,13 +937,13 @@ ei_device_get_name(struct ei_device *device);
/** /**
* The device type of the device is determined by the type of the ei * The device type of the device is determined by the type of the ei
* context. If the client context was created with ei_new_active(), the device * context. If the client context was created with ei_new_sender(), the device
* type defaults to @ref EI_DEVICE_TYPE_VIRTUAL. If the client context was * type defaults to @ref EI_DEVICE_TYPE_VIRTUAL. If the client context was
* created with ei_new_passive(), the device type defaults to @ref * created with ei_new_receiver(), the device type defaults to @ref
* EI_DEVICE_TYPE_PHYSICAL. * EI_DEVICE_TYPE_PHYSICAL.
* *
* libei does not currently support virtual devices on a passive context or * libei does not currently support virtual devices on a receiver context or
* physical devices on an active context. This may change in the future, * physical devices on an sender context. This may change in the future,
* applications should not rely on the type being fixed. * applications should not rely on the type being fixed.
*/ */
enum ei_device_type enum ei_device_type

View file

@ -80,9 +80,9 @@ eis_client_get_context(struct eis_client *client)
} }
_public_ bool _public_ bool
eis_client_is_active(struct eis_client *client) eis_client_is_sender(struct eis_client *client)
{ {
return client->is_active; return client->is_sender;
} }
static struct eis_device * static struct eis_device *
@ -263,10 +263,10 @@ client_msg_bind_seat(struct eis_client *client, uint32_t seatid, uint32_t caps)
return seat ? 0 : -EINVAL; return seat ? 0 : -EINVAL;
} }
#define DISCONNECT_IF_ACTIVE_CONTEXT(client_) do { \ #define DISCONNECT_IF_RECEIVER_CONTEXT(client_) do { \
if (!(client_)->is_active) { \ if (!(client_)->is_sender) { \
struct eis *_ctx = eis_client_get_context(client_); \ struct eis *_ctx = eis_client_get_context(client_); \
log_bug_client(_ctx, "Invalid event from passive ei context. Disconnecting client\n"); \ log_bug_client(_ctx, "Invalid event from receiver ei context. Disconnecting client\n"); \
return -EINVAL; \ return -EINVAL; \
} \ } \
} while(0) } while(0)
@ -274,7 +274,7 @@ client_msg_bind_seat(struct eis_client *client, uint32_t seatid, uint32_t caps)
static int static int
client_msg_start_emulating(struct eis_client *client, uint32_t deviceid) client_msg_start_emulating(struct eis_client *client, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -287,7 +287,7 @@ client_msg_start_emulating(struct eis_client *client, uint32_t deviceid)
static int static int
client_msg_stop_emulating(struct eis_client *client, uint32_t deviceid) client_msg_stop_emulating(struct eis_client *client, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -300,7 +300,7 @@ client_msg_stop_emulating(struct eis_client *client, uint32_t deviceid)
static int static int
client_msg_frame(struct eis_client *client, uint32_t deviceid) client_msg_frame(struct eis_client *client, uint32_t deviceid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -314,7 +314,7 @@ static int
client_msg_pointer_rel(struct eis_client *client, uint32_t deviceid, client_msg_pointer_rel(struct eis_client *client, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -328,7 +328,7 @@ static int
client_msg_pointer_abs(struct eis_client *client, uint32_t deviceid, client_msg_pointer_abs(struct eis_client *client, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -342,7 +342,7 @@ static int
client_msg_pointer_button(struct eis_client *client, uint32_t deviceid, client_msg_pointer_button(struct eis_client *client, uint32_t deviceid,
uint32_t button, bool state) uint32_t button, bool state)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -356,7 +356,7 @@ static int
client_msg_pointer_scroll(struct eis_client *client, uint32_t deviceid, client_msg_pointer_scroll(struct eis_client *client, uint32_t deviceid,
double x, double y) double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -370,7 +370,7 @@ static int
client_msg_pointer_scroll_discrete(struct eis_client *client, uint32_t deviceid, client_msg_pointer_scroll_discrete(struct eis_client *client, uint32_t deviceid,
int32_t x, int32_t y) int32_t x, int32_t y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -384,7 +384,7 @@ static int
client_msg_pointer_scroll_stop(struct eis_client *client, uint32_t deviceid, client_msg_pointer_scroll_stop(struct eis_client *client, uint32_t deviceid,
bool x, bool y, bool is_cancel) bool x, bool y, bool is_cancel)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -402,7 +402,7 @@ static int
client_msg_keyboard_key(struct eis_client *client, uint32_t deviceid, client_msg_keyboard_key(struct eis_client *client, uint32_t deviceid,
uint32_t key, bool state) uint32_t key, bool state)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -416,7 +416,7 @@ static int
client_msg_touch_down(struct eis_client *client, uint32_t deviceid, client_msg_touch_down(struct eis_client *client, uint32_t deviceid,
uint32_t touchid, double x, double y) uint32_t touchid, double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -430,7 +430,7 @@ static int
client_msg_touch_motion(struct eis_client *client, uint32_t deviceid, client_msg_touch_motion(struct eis_client *client, uint32_t deviceid,
uint32_t touchid, double x, double y) uint32_t touchid, double x, double y)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -443,7 +443,7 @@ client_msg_touch_motion(struct eis_client *client, uint32_t deviceid,
static int static int
client_msg_touch_up(struct eis_client *client, uint32_t deviceid, uint32_t touchid) client_msg_touch_up(struct eis_client *client, uint32_t deviceid, uint32_t touchid)
{ {
DISCONNECT_IF_ACTIVE_CONTEXT(client); DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid); struct eis_device *device = eis_client_find_device(client, deviceid);
@ -479,12 +479,12 @@ client_msg_configure_capabilities(struct eis_client *client, uint32_t allowed_ca
} }
static int static int
client_msg_connect(struct eis_client *client, const char *name, bool is_active) client_msg_connect(struct eis_client *client, const char *name, bool is_sender)
{ {
if (client->name == NULL) if (client->name == NULL)
client->name = xstrdup(name); client->name = xstrdup(name);
client->is_active = is_active; client->is_sender = is_sender;
return 0; return 0;
} }
@ -619,7 +619,7 @@ eis_client_new(struct eis *eis, int fd)
static uint32_t client_id; static uint32_t client_id;
struct eis_client *client = eis_client_create(&eis->object); struct eis_client *client = eis_client_create(&eis->object);
client->is_active = true; client->is_sender = true;
client->id = ++client_id; client->id = ++client_id;
list_init(&client->seats); list_init(&client->seats);
list_init(&client->seats_pending); list_init(&client->seats_pending);

View file

@ -71,7 +71,7 @@ struct eis_client {
uint32_t id; uint32_t id;
enum eis_client_state state; enum eis_client_state state;
char *name; char *name;
bool is_active; bool is_sender;
struct list seats; struct list seats;
struct list seats_pending; struct list seats_pending;

View file

@ -511,7 +511,7 @@ eis_proto_handle_message(struct eis_client *client,
int rc; int rc;
switch (proto->msg_case) { switch (proto->msg_case) {
case CLIENT_MESSAGE__MSG_CONNECT: case CLIENT_MESSAGE__MSG_CONNECT:
rc = call(connect, client, proto->connect->name, proto->connect->is_active); rc = call(connect, client, proto->connect->name, proto->connect->is_sender);
break; break;
case CLIENT_MESSAGE__MSG_CONNECT_DONE: case CLIENT_MESSAGE__MSG_CONNECT_DONE:
rc = call(connect_done, client); rc = call(connect_done, client);

View file

@ -36,7 +36,7 @@
/* callbacks invoked during eis_proto_parse_message() */ /* callbacks invoked during eis_proto_parse_message() */
struct eis_proto_interface { struct eis_proto_interface {
int (*connect)(struct eis_client *client, const char *name, bool is_active); int (*connect)(struct eis_client *client, const char *name, bool is_sender);
int (*connect_done)(struct eis_client *client); int (*connect_done)(struct eis_client *client);
int (*disconnect)(struct eis_client *client); int (*disconnect)(struct eis_client *client);
int (*bind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap); int (*bind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap);

View file

@ -39,16 +39,17 @@ extern "C" {
* libeis is the server-side module. This API should be used by processes * libeis is the server-side module. This API should be used by processes
* that have control over input devices, e.g. Wayland compositors. * that have control over input devices, e.g. Wayland compositors.
* *
* libei clients come in "active" and "passive" modes, depending on whether * libei clients come in "sender" and "receiver" modes, depending on whether
* the client sends or receives events. A libeis context however is both * the client sends or receives events. A libeis context however may accept
* active and passive at the same time, it is up to the implementation to * both sender and receiver clients, the EIS implementation works as
* disconnect clients that it does not want to allow. See * corresponding receiver or sender for this client. It is up to the
* eis_client_is_active() for details. * implementation to disconnect clients that it does not want to allow. See
* eis_client_is_sender() for details.
* *
* Note that usually the differentiation between active and passive client * Note that usually the differentiation between sender and receiver client
* has an effect on the devices that should be sent to the client. Active * has an effect on the devices that should be sent to the client. Sender
* clients typically expect devices representing the available screen area so * clients typically expect devices representing the available screen area so
* they can control input, passive clients typically expect devices * they can control input, receiver clients typically expect devices
* representing the physical input devices. * representing the physical input devices.
* *
* @{ * @{
@ -181,7 +182,7 @@ enum eis_event_type {
* and notifies the server that the previous set of events belong to * and notifies the server that the previous set of events belong to
* the same logical hardware event. * the same logical hardware event.
* *
* These events are only generated on a passive EIS context. * These events are only generated on a receiving EIS context.
* *
* This event is most commonly used to implement multitouch (multiple * This event is most commonly used to implement multitouch (multiple
* touches may update within the same hardware scanout cycle). * touches may update within the same hardware scanout cycle).
@ -193,7 +194,7 @@ enum eis_event_type {
* be used by the server to clear the logical state of the emulated * be used by the server to clear the logical state of the emulated
* devices and/or provide UI to the user. * devices and/or provide UI to the user.
* *
* These events are only generated on a passive EIS context. * These events are only generated on a receiving EIS context.
* *
* Note that a client start multiple emulating sequences * Note that a client start multiple emulating sequences
* simultaneously, depending on the devices it received from the * simultaneously, depending on the devices it received from the
@ -210,7 +211,7 @@ enum eis_event_type {
*/ */
EIS_EVENT_DEVICE_STOP_EMULATING, EIS_EVENT_DEVICE_STOP_EMULATING,
/* These events are only generated on a passive EIS context */ /* These events are only generated on a receiving EIS context */
/** /**
* A relative motion event with delta coordinates in logical pixels or * A relative motion event with delta coordinates in logical pixels or
@ -331,12 +332,12 @@ void
eis_set_user_data(struct eis *eis, void *user_data); eis_set_user_data(struct eis *eis, void *user_data);
/** /**
* Returns true if the client is active, false otherwise. An active client may * Returns true if the client is a sender, false otherwise. A sender client may
* send events to the EIS implementation, a passive client expects to receive * send events to the EIS implementation, a receiver client expects to receive
* events from the EIS implementation. * events from the EIS implementation.
*/ */
bool bool
eis_client_is_active(struct eis_client *client); eis_client_is_sender(struct eis_client *client);
/** /**
* See eis_client_property_set_with_permissions(), but the permissions are * See eis_client_property_set_with_permissions(), but the permissions are

View file

@ -54,7 +54,7 @@ struct source {
void *user_data; void *user_data;
enum source_close_behavior close_behavior; enum source_close_behavior close_behavior;
int fd; int fd;
bool is_active; bool is_sender;
}; };
OBJECT_IMPLEMENT_REF(source); OBJECT_IMPLEMENT_REF(source);
@ -70,13 +70,13 @@ OBJECT_IMPLEMENT_SETTER(source, user_data, void*);
void void
source_remove(struct source *source) source_remove(struct source *source)
{ {
if (!source || !source->is_active) if (!source || !source->is_sender)
return; return;
epoll_ctl(source->sink->epollfd, EPOLL_CTL_DEL, source->fd, NULL); epoll_ctl(source->sink->epollfd, EPOLL_CTL_DEL, source->fd, NULL);
if (source->close_behavior == SOURCE_CLOSE_FD_ON_REMOVE) if (source->close_behavior == SOURCE_CLOSE_FD_ON_REMOVE)
source->fd = xclose(source->fd); source->fd = xclose(source->fd);
source->is_active = false; source->is_sender = false;
source_unref(source); source_unref(source);
/* Note: sources list was the owner of the source, new owner /* Note: sources list was the owner of the source, new owner
@ -91,7 +91,7 @@ static void
source_destroy(struct source *source) source_destroy(struct source *source)
{ {
/* We expect source_remove() to be called before we ever get here */ /* We expect source_remove() to be called before we ever get here */
assert(!source->is_active); assert(!source->is_sender);
if (source->close_behavior == SOURCE_CLOSE_FD_ON_DESTROY) if (source->close_behavior == SOURCE_CLOSE_FD_ON_DESTROY)
source->fd = xclose(source->fd); source->fd = xclose(source->fd);
@ -109,7 +109,7 @@ source_new(int sourcefd, source_dispatch_t dispatch, void *user_data)
source->user_data = user_data; source->user_data = user_data;
source->fd = sourcefd; source->fd = sourcefd;
source->close_behavior = SOURCE_CLOSE_FD_ON_REMOVE; source->close_behavior = SOURCE_CLOSE_FD_ON_REMOVE;
source->is_active = false; source->is_sender = false;
list_init(&source->link); list_init(&source->link);
return source; return source;
@ -202,7 +202,7 @@ sink_add_source(struct sink *sink, struct source *source)
return -errno; return -errno;
} }
source->is_active = true; source->is_sender = true;
source->sink = sink; source->sink = sink;
source_ref(source); source_ref(source);
list_append(&sink->sources, &source->link); list_append(&sink->sources, &source->link);

View file

@ -318,13 +318,13 @@ peck_new_context(enum peck_ei_mode ei_mode)
{ {
struct peck *peck = peck_create(NULL); struct peck *peck = peck_create(NULL);
assert(ei_mode == PECK_EI_PASSIVE || ei_mode == PECK_EI_ACTIVE); assert(ei_mode == PECK_EI_RECEIVER || ei_mode == PECK_EI_SENDER);
int sv[2]; int sv[2];
int rc = socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, sv); int rc = socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, sv);
munit_assert_int(rc, ==, 0); munit_assert_int(rc, ==, 0);
struct ei *ei = ei_mode == PECK_EI_PASSIVE ? ei_new_passive(peck) : ei_new_active(peck); struct ei *ei = ei_mode == PECK_EI_RECEIVER ? ei_new_receiver(peck) : ei_new_sender(peck);
ei_set_user_data(ei, peck); ei_set_user_data(ei, peck);
ei_log_set_handler(ei, peck_ei_log_handler); ei_log_set_handler(ei, peck_ei_log_handler);
ei_log_set_priority(ei, EI_LOG_PRIORITY_DEBUG); ei_log_set_priority(ei, EI_LOG_PRIORITY_DEBUG);
@ -357,7 +357,7 @@ peck_new_context(enum peck_ei_mode ei_mode)
struct peck * struct peck *
peck_new(void) peck_new(void)
{ {
return peck_new_context(PECK_EI_ACTIVE); return peck_new_context(PECK_EI_SENDER);
} }
void void
@ -856,7 +856,7 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
case EI_EVENT_DEVICE_RESUMED: case EI_EVENT_DEVICE_RESUMED:
if (flag_is_set(peck->ei_behavior, PECK_EI_BEHAVIOR_AUTOSTART)) { if (flag_is_set(peck->ei_behavior, PECK_EI_BEHAVIOR_AUTOSTART)) {
struct ei_device *device = ei_event_get_device(e); struct ei_device *device = ei_event_get_device(e);
if (ei_is_active(ei_device_get_context(device))) if (ei_is_sender(ei_device_get_context(device)))
ei_device_start_emulating(device); ei_device_start_emulating(device);
} }
break; break;

View file

@ -32,8 +32,8 @@
#include "util-mem.h" #include "util-mem.h"
enum peck_ei_mode { enum peck_ei_mode {
PECK_EI_PASSIVE = 20, PECK_EI_RECEIVER = 20,
PECK_EI_ACTIVE, PECK_EI_SENDER,
}; };
/** /**

View file

@ -1150,7 +1150,7 @@ MUNIT_TEST(test_ei_keyboard_modifiers)
MUNIT_TEST(test_passive_ei_device_start_stop_emulating) MUNIT_TEST(test_passive_ei_device_start_stop_emulating)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_DEFAULT_SEAT); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_DEFAULT_SEAT);
@ -1186,7 +1186,7 @@ MUNIT_TEST(test_passive_ei_device_start_stop_emulating)
MUNIT_TEST(test_passive_ei_device_stop_emulating_when_removing) MUNIT_TEST(test_passive_ei_device_stop_emulating_when_removing)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_DEFAULT_SEAT); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_DEFAULT_SEAT);
@ -1225,7 +1225,7 @@ MUNIT_TEST(test_passive_ei_device_stop_emulating_when_removing)
/* Same as test_passive_ei_device_pointer_rel() but for a passive context */ /* Same as test_passive_ei_device_pointer_rel() but for a passive context */
MUNIT_TEST(test_passive_ei_device_keyboard_key) MUNIT_TEST(test_passive_ei_device_keyboard_key)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_KEYBOARD); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_KEYBOARD);
@ -1272,7 +1272,7 @@ MUNIT_TEST(test_passive_ei_device_keyboard_key)
/* Same as test_ei_device_pointer_rel() but for a passive context */ /* Same as test_ei_device_pointer_rel() but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_rel) MUNIT_TEST(test_passive_ei_device_pointer_rel)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
@ -1326,7 +1326,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_rel)
/* Same as test_ei_device_pointer_abs() but for a passive context */ /* Same as test_ei_device_pointer_abs() but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_abs) MUNIT_TEST(test_passive_ei_device_pointer_abs)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
struct eis_device *device = NULL; struct eis_device *device = NULL;
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
@ -1407,7 +1407,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_abs)
/* same as test_ei_device_pointer_scroll but for a passive context */ /* same as test_ei_device_pointer_scroll but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_scroll) MUNIT_TEST(test_passive_ei_device_pointer_scroll)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
@ -1454,7 +1454,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll)
/* same as test_ei_device_pointer_scroll_stop but for a passive context */ /* same as test_ei_device_pointer_scroll_stop but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop) MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
@ -1536,7 +1536,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop)
/* same as test_ei_device_pointer_scroll_cancel but for a passive context */ /* same as test_ei_device_pointer_scroll_cancel but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel) MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
@ -1618,7 +1618,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel)
/* same as test_ei_device_pointer_scroll_stop_cancel but for a passive context */ /* same as test_ei_device_pointer_scroll_stop_cancel but for a passive context */
MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel) MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_POINTER);
@ -1689,7 +1689,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel)
/* same as test_ei_device_touch but for a passive context */ /* same as test_ei_device_touch but for a passive context */
MUNIT_TEST(test_passive_ei_device_touch) MUNIT_TEST(test_passive_ei_device_touch)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
struct eis_device *device = NULL; struct eis_device *device = NULL;
uint32_t maxx = 0, maxy = 0; uint32_t maxx = 0, maxy = 0;
@ -1874,7 +1874,7 @@ MUNIT_TEST(test_passive_ei_device_touch)
/* same as test_ei_device_multitouch but for a passive context */ /* same as test_ei_device_multitouch but for a passive context */
MUNIT_TEST(test_passive_ei_device_multitouch) MUNIT_TEST(test_passive_ei_device_multitouch)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_TOUCH); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_TOUCH);

View file

@ -868,9 +868,9 @@ MUNIT_TEST(test_ei_disconnect_after_unbind_after_received)
return MUNIT_OK; return MUNIT_OK;
} }
MUNIT_TEST(test_client_is_active) MUNIT_TEST(test_client_is_sender)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_ACTIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_SENDER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE);
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_NONE); peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_NONE);
@ -880,15 +880,15 @@ MUNIT_TEST(test_client_is_active)
with_server(peck) { with_server(peck) {
_unref_(eis_event) *connect = peck_eis_next_event(eis, EIS_EVENT_CLIENT_CONNECT); _unref_(eis_event) *connect = peck_eis_next_event(eis, EIS_EVENT_CLIENT_CONNECT);
struct eis_client *client = eis_event_get_client(connect); struct eis_client *client = eis_event_get_client(connect);
munit_assert_true(eis_client_is_active(client)); munit_assert_true(eis_client_is_sender(client));
} }
return MUNIT_OK; return MUNIT_OK;
} }
MUNIT_TEST(test_client_is_passive) MUNIT_TEST(test_client_is_receiver)
{ {
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE); _unref_(peck) *peck = peck_new_context(PECK_EI_RECEIVER);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE); peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_NONE);
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_NONE); peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_NONE);
@ -898,7 +898,7 @@ MUNIT_TEST(test_client_is_passive)
with_server(peck) { with_server(peck) {
_unref_(eis_event) *connect = peck_eis_next_event(eis, EIS_EVENT_CLIENT_CONNECT); _unref_(eis_event) *connect = peck_eis_next_event(eis, EIS_EVENT_CLIENT_CONNECT);
struct eis_client *client = eis_event_get_client(connect); struct eis_client *client = eis_event_get_client(connect);
munit_assert_false(eis_client_is_active(client)); munit_assert_false(eis_client_is_sender(client));
} }
return MUNIT_OK; return MUNIT_OK;

View file

@ -177,7 +177,7 @@ usage(FILE *fp, const char *argv0)
" --portal Use the portal backend.\n" " --portal Use the portal backend.\n"
" --busname Use the given busname (default: org.freedesktop.portal.Desktop)\n" " --busname Use the given busname (default: org.freedesktop.portal.Desktop)\n"
" --verbose Enable debugging output\n" " --verbose Enable debugging output\n"
" --passive Create an passive EIS context, receiving events instead of sending them\n" " --receiver Create a receiver EIS context, receiving events instead of sending them\n"
"", "",
argv0); argv0);
} }
@ -189,7 +189,7 @@ int main(int argc, char **argv)
PORTAL, PORTAL,
} backend = SOCKET; } backend = SOCKET;
bool verbose = false; bool verbose = false;
bool passive = false; bool receiver = false;
_cleanup_free_ char *busname = xstrdup("org.freedesktop.portal.Desktop"); _cleanup_free_ char *busname = xstrdup("org.freedesktop.portal.Desktop");
while (1) { while (1) {
@ -198,14 +198,14 @@ int main(int argc, char **argv)
OPT_BACKEND_PORTAL, OPT_BACKEND_PORTAL,
OPT_BUSNAME, OPT_BUSNAME,
OPT_VERBOSE, OPT_VERBOSE,
OPT_PASSIVE, OPT_RECEIVER,
}; };
static struct option long_opts[] = { static struct option long_opts[] = {
{"socket", no_argument, 0, OPT_BACKEND_SOCKET}, {"socket", no_argument, 0, OPT_BACKEND_SOCKET},
{"portal", no_argument, 0, OPT_BACKEND_PORTAL}, {"portal", no_argument, 0, OPT_BACKEND_PORTAL},
{"busname", required_argument, 0, OPT_BUSNAME}, {"busname", required_argument, 0, OPT_BUSNAME},
{"verbose", no_argument, 0, OPT_VERBOSE}, {"verbose", no_argument, 0, OPT_VERBOSE},
{"passive", no_argument, 0, OPT_PASSIVE}, {"receiver", no_argument, 0, OPT_RECEIVER},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{.name = NULL}, {.name = NULL},
}; };
@ -232,8 +232,8 @@ int main(int argc, char **argv)
free(busname); free(busname);
busname = xstrdup(optarg); busname = xstrdup(optarg);
break; break;
case OPT_PASSIVE: case OPT_RECEIVER:
passive = true; receiver = true;
break; break;
default: default:
usage(stderr, argv[0]); usage(stderr, argv[0]);
@ -242,10 +242,10 @@ int main(int argc, char **argv)
} }
_unref_(ei) *ei = NULL; _unref_(ei) *ei = NULL;
if (passive) if (receiver)
ei = ei_new_passive(NULL); ei = ei_new_receiver(NULL);
else else
ei = ei_new_active(NULL); ei = ei_new_sender(NULL);
assert(ei); assert(ei);
if (verbose) if (verbose)
@ -346,19 +346,19 @@ int main(int argc, char **argv)
break; break;
case EI_EVENT_DEVICE_RESUMED: case EI_EVENT_DEVICE_RESUMED:
if (ei_event_get_device(e) == ptr) { if (ei_event_get_device(e) == ptr) {
if (!passive) if (!receiver)
ei_device_start_emulating(ptr); ei_device_start_emulating(ptr);
colorprint("Pointer device was resumed\n"); colorprint("Pointer device was resumed\n");
have_ptr = true; have_ptr = true;
} }
if (ei_event_get_device(e) == kbd) { if (ei_event_get_device(e) == kbd) {
if (!passive) if (!receiver)
ei_device_start_emulating(kbd); ei_device_start_emulating(kbd);
colorprint("Keyboard device was resumed\n"); colorprint("Keyboard device was resumed\n");
have_kbd = true; have_kbd = true;
} }
if (ei_event_get_device(e) == abs) { if (ei_event_get_device(e) == abs) {
if (!passive) if (!receiver)
ei_device_start_emulating(abs); ei_device_start_emulating(abs);
colorprint("Abs pointer device was resumed\n"); colorprint("Abs pointer device was resumed\n");
have_abs = true; have_abs = true;
@ -444,7 +444,7 @@ int main(int argc, char **argv)
} }
} }
if (!passive) { if (!receiver) {
if (have_ptr) { if (have_ptr) {
colorprint("sending motion event\n"); colorprint("sending motion event\n");
ei_device_pointer_motion(ptr, -1, 1); ei_device_pointer_motion(ptr, -1, 1);

View file

@ -216,7 +216,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_client_get_name(client)); eis_client_get_name(client));
eis_device_add(ptr); eis_device_add(ptr);
eis_device_resume(ptr); eis_device_resume(ptr);
if (!eis_client_is_active(client)) if (!eis_client_is_sender(client))
eis_device_start_emulating(ptr); eis_device_start_emulating(ptr);
device = steal(&ptr); device = steal(&ptr);
break; break;
@ -234,7 +234,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_client_get_name(client)); eis_client_get_name(client));
eis_device_add(abs); eis_device_add(abs);
eis_device_resume(abs); eis_device_resume(abs);
if (!eis_client_is_active(client)) if (!eis_client_is_sender(client))
eis_device_start_emulating(abs); eis_device_start_emulating(abs);
device = steal(&abs); device = steal(&abs);
break; break;
@ -250,7 +250,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_client_get_name(client)); eis_client_get_name(client));
eis_device_add(kbd); eis_device_add(kbd);
eis_device_resume(kbd); eis_device_resume(kbd);
if (!eis_client_is_active(client)) if (!eis_client_is_sender(client))
eis_device_start_emulating(kbd); eis_device_start_emulating(kbd);
device = steal(&kbd); device = steal(&kbd);
break; break;
@ -281,9 +281,9 @@ eis_demo_server_printf_handle_event(struct eis_demo_server *server,
const char *pid = eis_client_property_get(client, "ei.application.pid"); const char *pid = eis_client_property_get(client, "ei.application.pid");
const char *cmdline = eis_client_property_get(client, "ei.application.cmdline"); const char *cmdline = eis_client_property_get(client, "ei.application.cmdline");
const char *ctype = eis_client_property_get(client, "ei.connection.type"); const char *ctype = eis_client_property_get(client, "ei.connection.type");
bool is_active = eis_client_is_active(client); bool is_sender = eis_client_is_sender(client);
colorprint("new %s client: %s (pid %s, '%s'), connected via %s\n", colorprint("new %s client: %s (pid %s, '%s'), connected via %s\n",
is_active ? "active" : "passive", is_sender ? "sender" : "receiver",
eis_client_get_name(client), eis_client_get_name(client),
pid, cmdline, ctype); pid, cmdline, ctype);
@ -454,7 +454,7 @@ usage(FILE *fp, const char *argv0)
" --layout Use the given XKB layout (requires libxkbcommon). Default: none\n" " --layout Use the given XKB layout (requires libxkbcommon). Default: none\n"
" --uinput Set up each device as uinput device (this requires root)\n" " --uinput Set up each device as uinput device (this requires root)\n"
" --verbose Enable debugging output\n" " --verbose Enable debugging output\n"
" --active Make this an active EIS server, sending events instead of receiving them\n" " --sender Make this a sender EIS server, sending events instead of receiving them\n"
"", "",
argv0); argv0);
} }
@ -575,7 +575,7 @@ int main(int argc, char **argv)
struct eis_demo_client *democlient; struct eis_demo_client *democlient;
list_for_each(democlient, &server.clients, link) { list_for_each(democlient, &server.clients, link) {
if (eis_client_is_active(democlient->client)) if (eis_client_is_sender(democlient->client))
continue; continue;
struct eis_device *ptr = democlient->ptr; struct eis_device *ptr = democlient->ptr;