Add a sequence number to START_EMULATING

This makes it easier to correlate a particular input transaction
(whether there are events or not) with out-of-band information like the
planned portal InputCapture::Activated signal's "activation-id".
This commit is contained in:
Peter Hutterer 2023-01-30 10:31:07 +10:00
parent a5cc87c837
commit ff9830c122
22 changed files with 155 additions and 56 deletions

View file

@ -133,6 +133,7 @@ message TouchUp {
message StartEmulating {
fixed32 deviceid = 1;
fixed32 sequence = 2;
}
message StopEmulating {

View file

@ -375,7 +375,7 @@ _flush_frame(struct ei_device *device, const char *func)
#define ei_device_flush_frame(d_) _flush_frame(d_, __func__)
_public_ void
ei_device_start_emulating(struct ei_device *device)
ei_device_start_emulating(struct ei_device *device, uint32_t sequence)
{
if (device->state != EI_DEVICE_STATE_RESUMED)
return;
@ -383,7 +383,7 @@ ei_device_start_emulating(struct ei_device *device)
assert(!device->send_frame_event);
device->state = EI_DEVICE_STATE_EMULATING;
ei_send_start_emulating(device);
ei_send_start_emulating(device, sequence);
}
_public_ void
@ -756,7 +756,7 @@ ei_device_frame(struct ei_device *device, uint64_t time)
}
void
ei_device_event_start_emulating(struct ei_device *device)
ei_device_event_start_emulating(struct ei_device *device, uint32_t sequence)
{
switch (device->state) {
case EI_DEVICE_STATE_DEAD:
@ -765,7 +765,7 @@ ei_device_event_start_emulating(struct ei_device *device)
case EI_DEVICE_STATE_EMULATING:
break;
case EI_DEVICE_STATE_RESUMED:
ei_queue_device_start_emulating_event(device);
ei_queue_device_start_emulating_event(device, sequence);
device->state = EI_DEVICE_STATE_EMULATING;
break;
case EI_DEVICE_STATE_REMOVED_FROM_CLIENT:

View file

@ -163,6 +163,13 @@ check_event_type(struct ei_event *event,
if (!check_event_type(event_, __func__, __VA_ARGS__, -1)) \
return retval_; \
_public_ uint32_t
ei_event_emulating_get_sequence(struct ei_event *event)
{
require_event_type(event, 0, EI_EVENT_DEVICE_START_EMULATING);
return event->start_emulating.sequence;
}
_public_ uint32_t
ei_event_keyboard_get_xkb_mods_depressed(struct ei_event *event)

View file

@ -205,6 +205,9 @@ struct ei_event {
uint32_t touchid;
double x, y;
} touch;
struct {
uint32_t sequence;
} start_emulating;
};
};
@ -249,7 +252,7 @@ int
ei_send_close_device(struct ei_device *device);
int
ei_send_start_emulating(struct ei_device *device);
ei_send_start_emulating(struct ei_device *device, uint32_t sequence);
int
ei_send_stop_emulating(struct ei_device *device);
@ -267,7 +270,7 @@ void
ei_queue_seat_removed_event(struct ei_seat *seat);
void
ei_queue_device_start_emulating_event(struct ei_device *device);
ei_queue_device_start_emulating_event(struct ei_device *device, uint32_t sequence);
void
ei_queue_device_stop_emulating_event(struct ei_device *device);
@ -326,7 +329,7 @@ int
ei_device_event_frame(struct ei_device *device, uint64_t time);
void
ei_device_event_start_emulating(struct ei_device *device);
ei_device_event_start_emulating(struct ei_device *device, uint32_t sequence);
void
ei_device_event_stop_emulating(struct ei_device *device);

View file

@ -134,7 +134,8 @@ ei_proto_handle_message(struct ei *ei,
/* Events */
case SERVER_MESSAGE__MSG_START_EMULATING:
rc = call(start_emulating, ei,
proto->start_emulating->deviceid);
proto->start_emulating->deviceid,
proto->start_emulating->sequence);
break;
case SERVER_MESSAGE__MSG_STOP_EMULATING:
rc = call(stop_emulating, ei,
@ -356,11 +357,12 @@ ei_proto_send_close_device(struct ei_device *device)
}
static int
ei_proto_send_start_emulating(struct ei_device *device)
ei_proto_send_start_emulating(struct ei_device *device, uint32_t sequence)
{
prepare_msg(START_EMULATING, StartEmulating, start_emulating);
start_emulating.deviceid = device->id;
start_emulating.sequence = sequence;
return ei_proto_send_msg(ei_device_get_context(device), &msg);
}

View file

@ -58,7 +58,7 @@ struct ei_proto_interface {
int (*version)(struct ei *ei, uint32_t version);
/* events */
int (*start_emulating)(struct ei *ei, uint32_t deviceid);
int (*start_emulating)(struct ei *ei, uint32_t deviceid, uint32_t sequence);
int (*stop_emulating)(struct ei *ei, uint32_t deviceid);
int (*rel)(struct ei *ei, uint32_t deviceid, double x, double y);
int (*abs)(struct ei *ei, uint32_t deviceid, double x, double y);
@ -83,7 +83,7 @@ struct ei_proto_requests {
int (*unbind_seat)(struct ei_seat *seat, enum ei_device_capability cap);
int (*close_device)(struct ei_device *device);
int (*get_version)(struct ei *ei);
int (*start_emulating)(struct ei_device *device);
int (*start_emulating)(struct ei_device *device, uint32_t sequence);
int (*stop_emulating)(struct ei_device *device);
int (*rel)(struct ei_device *device, double x, double y);

View file

@ -406,11 +406,12 @@ ei_queue_frame_event(struct ei_device *device, uint64_t time)
}
void
ei_queue_device_start_emulating_event(struct ei_device *device)
ei_queue_device_start_emulating_event(struct ei_device *device, uint32_t sequence)
{
struct ei_event *e = ei_event_new_for_device(device);
e->type = EI_EVENT_DEVICE_START_EMULATING;
e->start_emulating.sequence = sequence;
queue_event(ei_device_get_context(device), e);
}
@ -824,14 +825,14 @@ ei_send_close_device(struct ei_device *device)
}
int
ei_send_start_emulating(struct ei_device *device)
ei_send_start_emulating(struct ei_device *device, uint32_t sequence)
{
struct ei *ei = ei_device_get_context(device);
if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED)
return 0;
int rc = ei->requests->start_emulating(device);
int rc = ei->requests->start_emulating(device, sequence);
if (rc)
ei_disconnect(ei);
return rc;
@ -1099,14 +1100,14 @@ static int handle_msg_disconnected(struct ei *ei) {
} while(0)
static int
handle_msg_start_emulating(struct ei *ei, uint32_t deviceid)
handle_msg_start_emulating(struct ei *ei, uint32_t deviceid, uint32_t sequence)
{
DISCONNECT_IF_SENDER_CONTEXT(ei);
struct ei_device *device = ei_find_device(ei, deviceid);
if (device)
ei_device_event_start_emulating(device);
ei_device_event_start_emulating(device, sequence);
return 0;
}

View file

@ -1068,9 +1068,10 @@ ei_device_get_context(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
* time-based boundary. The primary use-cases for this are to allow for setup on
* the EIS implementation side and/or UI updates to indicate that a device is
* sending events now.
* sending events now and for out-of-band information to sync with a given event
* sequence.
*
* There is no actual requirement that events start immediately once emulation
* starts and there is no requirement that a client calls
@ -1082,9 +1083,15 @@ ei_device_get_context(struct ei_device *device);
*
* Sending events before ei_device_start_emulating() or after
* ei_device_stop_emulating() is a client bug.
*
* The sequence number identifies this transaction between start/stop emulating.
* It must go up by at least 1 on each call to
* ei_device_start_emulating(). Wraparound must be handled by the EIS
* implementation but Callers must ensure that detection of wraparound is
* reasonably.
*/
void
ei_device_start_emulating(struct ei_device *device);
ei_device_start_emulating(struct ei_device *device, uint32_t sequence);
/**
* Notify the EIS implementation that the given device is no longer sending
@ -1354,6 +1361,15 @@ ei_touch_get_device(struct ei_touch *touch);
struct ei_seat *
ei_event_get_seat(struct ei_event *event);
/**
* For an event of type @ref EI_EVENT_DEVICE_START_EMULATING, return the
* sequence number set by the EIS implementation.
*
* See eis_device_start_emulating() for details.
*/
uint32_t
ei_event_emulating_get_sequence(struct ei_event *event);
/**
* For an event of type @ref EI_EVENT_POINTER_MOTION return the relative x
* movement in logical pixels or mm, depending on the device type.

View file

@ -299,14 +299,14 @@ client_msg_bind_seat(struct eis_client *client, uint32_t seatid, uint32_t caps)
} while(0)
static int
client_msg_start_emulating(struct eis_client *client, uint32_t deviceid)
client_msg_start_emulating(struct eis_client *client, uint32_t deviceid, uint32_t sequence)
{
DISCONNECT_IF_RECEIVER_CONTEXT(client);
struct eis_device *device = eis_client_find_device(client, deviceid);
if (device)
eis_device_event_start_emulating(device);
eis_device_event_start_emulating(device, sequence);
return 0;
}

View file

@ -336,7 +336,7 @@ _flush_frame(struct eis_device *device, const char *func)
#define eis_device_flush_frame(d_) _flush_frame(d_, __func__)
_public_ void
eis_device_start_emulating(struct eis_device *device)
eis_device_start_emulating(struct eis_device *device, uint32_t sequence)
{
if (device->state != EIS_DEVICE_STATE_RESUMED)
return;
@ -345,7 +345,7 @@ eis_device_start_emulating(struct eis_device *device)
device->state = EIS_DEVICE_STATE_EMULATING;
handle_request_noargs(device, start_emulating);
handle_request(device, start_emulating, sequence);
}
_public_ void
@ -930,7 +930,7 @@ eis_device_closed_by_client(struct eis_device *device)
}
void
eis_device_event_start_emulating(struct eis_device *device)
eis_device_event_start_emulating(struct eis_device *device, uint32_t sequence)
{
switch (device->state) {
case EIS_DEVICE_STATE_DEAD:
@ -939,7 +939,7 @@ eis_device_event_start_emulating(struct eis_device *device)
case EIS_DEVICE_STATE_PAUSED:
break;
case EIS_DEVICE_STATE_RESUMED:
eis_queue_device_start_emulating_event(device);
eis_queue_device_start_emulating_event(device, sequence);
device->state = EIS_DEVICE_STATE_EMULATING;
break;
case EIS_DEVICE_STATE_EMULATING:

View file

@ -195,6 +195,14 @@ eis_event_seat_has_capability(struct eis_event *event, enum eis_device_capabilit
return flag_is_set(event->bind.capabilities, cap);
}
_public_ uint32_t
eis_event_emulating_get_sequence(struct eis_event *event)
{
require_event_type(event, 0, EIS_EVENT_DEVICE_START_EMULATING);
return event->start_emulating.sequence;
}
_public_ double
eis_event_pointer_get_dx(struct eis_event *event)
{

View file

@ -198,6 +198,9 @@ struct eis_event {
uint32_t touchid;
double x, y;
} touch;
struct {
uint32_t sequence;
} start_emulating;
};
};
@ -311,7 +314,7 @@ int
eis_device_event_touch_up(struct eis_device *device, uint32_t touchid);
void
eis_device_event_start_emulating(struct eis_device *device);
eis_device_event_start_emulating(struct eis_device *device, uint32_t sequence);
void
eis_device_event_stop_emulating(struct eis_device *device);
@ -353,7 +356,7 @@ void
eis_queue_frame_event(struct eis_device *device, uint64_t time);
void
eis_queue_device_start_emulating_event(struct eis_device *device);
eis_queue_device_start_emulating_event(struct eis_device *device, uint32_t sequence);
void
eis_queue_device_stop_emulating_event(struct eis_device *device);

View file

@ -277,11 +277,12 @@ eis_proto_send_device_resumed(struct eis_device *device)
}
static int
eis_proto_send_start_emulating(struct eis_device *device, uint32_t deviceid)
eis_proto_send_start_emulating(struct eis_device *device, uint32_t deviceid, uint32_t sequence)
{
prepare_msg(START_EMULATING, StartEmulating, start_emulating);
start_emulating.deviceid = device->id;
start_emulating.sequence = sequence;
return eis_proto_send_msg(eis_device_get_client(device), &msg);
}
@ -524,7 +525,8 @@ eis_proto_handle_message(struct eis_client *client,
/* Events */
case CLIENT_MESSAGE__MSG_START_EMULATING:
rc = call(start_emulating, client,
proto->start_emulating->deviceid);
proto->start_emulating->deviceid,
proto->start_emulating->sequence);
break;
case CLIENT_MESSAGE__MSG_STOP_EMULATING:
rc = call(stop_emulating, client,

View file

@ -44,7 +44,7 @@ struct eis_proto_interface {
int (*close_device)(struct eis_client *client, uint32_t deviceid);
int (*get_version)(struct eis_client *client);
/* events */
int (*start_emulating)(struct eis_client *client, uint32_t deviceid);
int (*start_emulating)(struct eis_client *client, uint32_t deviceid, uint32_t sequence);
int (*stop_emulating)(struct eis_client *client, uint32_t deviceid);
int (*rel)(struct eis_client *client, uint32_t deviceid, double x, double y);
int (*abs)(struct eis_client *client, uint32_t deviceid, double x, double y);
@ -79,7 +79,7 @@ struct eis_proto_requests {
int (*version)(struct eis_client *client, uint32_t version);
/* events */
int (*start_emulating)(struct eis_device *device, uint32_t deviceid);
int (*start_emulating)(struct eis_device *device, uint32_t deviceid, uint32_t sequence);
int (*stop_emulating)(struct eis_device *device, uint32_t deviceid);
int (*rel)(struct eis_device *device, uint32_t deviceid, double x, double y);
int (*abs)(struct eis_device *device, uint32_t deviceid, double x, double y);

View file

@ -257,7 +257,7 @@ eis_queue_frame_event(struct eis_device *device, uint64_t time)
}
void
eis_queue_device_start_emulating_event(struct eis_device *device)
eis_queue_device_start_emulating_event(struct eis_device *device, uint32_t sequence)
{
struct eis_event *e = eis_event_new_for_device(device);
e->type = EIS_EVENT_DEVICE_START_EMULATING;

View file

@ -879,7 +879,7 @@ eis_device_keyboard_send_xkb_modifiers(struct eis_device *device,
/** see @ref ei_device_start_emulating */
void
eis_device_start_emulating(struct eis_device *device);
eis_device_start_emulating(struct eis_device *device, uint32_t sequence);
/** see @ref ei_device_stop_emulating */
void
@ -990,6 +990,15 @@ eis_event_get_device(struct eis_event *event);
uint64_t
eis_event_get_time(struct eis_event *event);
/**
* For an event of type @ref EIS_EVENT_DEVICE_START_EMULATING, return the
* sequence number set by the ei client implementation.
*
* See ei_device_start_emulating() for details.
*/
uint32_t
eis_event_emulating_get_sequence(struct eis_event *event);
/**
* For an event of type @ref EIS_EVENT_POINTER_MOTION return the relative x
* movement in logical pixels or mm, depending on the device type.

View file

@ -953,9 +953,10 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
}
case EI_EVENT_DEVICE_RESUMED:
if (flag_is_set(peck->ei_behavior, PECK_EI_BEHAVIOR_AUTOSTART)) {
static uint32_t sequence;
struct ei_device *device = ei_event_get_device(e);
if (ei_is_sender(ei_device_get_context(device)))
ei_device_start_emulating(device);
ei_device_start_emulating(device, ++sequence);
}
break;
case EI_EVENT_DEVICE_PAUSED:

View file

@ -334,7 +334,7 @@ DEFINE_UNREF_CLEANUP_FUNC(eis_region);
of a test handles server vs client */
#define with_server(peck_) for (struct eis *eis = peck_get_eis(peck_); eis; eis = NULL)
#define with_client(peck_) for (struct ei *ei = peck_get_ei(peck_); ei; ei = NULL)
#define with_emulation(d_) for (bool _loop = ({ ei_device_start_emulating(d_); true;});\
#define with_emulation(d_, sequence_) for (bool _loop = ({ ei_device_start_emulating(d_, sequence_); true;});\
_loop; \
({ ei_device_stop_emulating(d_); _loop = false; }))

View file

@ -1341,9 +1341,11 @@ MUNIT_TEST(test_passive_ei_device_start_stop_emulating)
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
eis_device_stop_emulating(device);
}
peck_dispatch_until_stable(peck);
@ -1351,6 +1353,7 @@ MUNIT_TEST(test_passive_ei_device_start_stop_emulating)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
_unref_(ei_event) *stop =
peck_ei_next_event(ei, EI_EVENT_DEVICE_STOP_EMULATING);
}
@ -1377,9 +1380,11 @@ MUNIT_TEST(test_passive_ei_device_stop_emulating_when_removing)
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
eis_device_remove(device);
}
peck_dispatch_until_stable(peck);
@ -1387,6 +1392,7 @@ MUNIT_TEST(test_passive_ei_device_stop_emulating_when_removing)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
_unref_(ei_event) *stop =
peck_ei_next_event(ei, EI_EVENT_DEVICE_STOP_EMULATING);
_unref_(ei_event) *close =
@ -1406,9 +1412,11 @@ MUNIT_TEST(test_passive_ei_device_keyboard_key)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_keyboard(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1416,6 +1424,7 @@ MUNIT_TEST(test_passive_ei_device_keyboard_key)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1453,9 +1462,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_rel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 1234;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1463,6 +1474,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_rel)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1508,9 +1520,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_abs)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer_absolute(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1518,6 +1532,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_abs)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1589,9 +1604,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1599,6 +1616,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1636,9 +1654,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 456;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1646,6 +1666,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1718,9 +1739,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 546;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1728,6 +1751,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1800,9 +1824,11 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 456;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1810,6 +1836,7 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
/* cancel after stop is fine, stop after cancel is ignored */
@ -1873,9 +1900,11 @@ MUNIT_TEST(test_passive_ei_device_touch)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 123;
with_server(peck) {
device = peck_eis_get_default_touch(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
}
peck_dispatch_until_stable(peck);
@ -1883,6 +1912,7 @@ MUNIT_TEST(test_passive_ei_device_touch)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
}
with_server(peck) {
@ -1893,7 +1923,7 @@ MUNIT_TEST(test_passive_ei_device_touch)
maxx = eis_region_get_x(r) + eis_region_get_width(r);
maxy = eis_region_get_y(r) + eis_region_get_height(r);
eis_device_start_emulating(device);
eis_device_start_emulating(device, ++sequence);
_unref_(eis_touch) *t = eis_device_touch_new(device);
eis_touch_down(t, 1, 2);
@ -2061,11 +2091,13 @@ MUNIT_TEST(test_passive_ei_device_multitouch)
peck_dispatch_until_stable(peck);
uint32_t sequence = 345;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_touch(peck);
_unref_(eis_touch) *t1 = eis_device_touch_new(device);
_unref_(eis_touch) *t2 = eis_device_touch_new(device);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
eis_touch_down(t1, 1, 2);
eis_device_frame(device, peck_eis_now(peck));
eis_touch_motion(t1, 2, 3);
@ -2089,6 +2121,8 @@ MUNIT_TEST(test_passive_ei_device_multitouch)
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
_unref_(ei_event) *down1 = peck_ei_touch_down(ei, 1, 2);
uint32_t tid1 = ei_event_touch_get_id(down1);
@ -2129,9 +2163,11 @@ MUNIT_TEST(test_passive_ei_frame_timestamp)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 345;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_keyboard(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
ts1 = peck_eis_now(peck);
eis_device_keyboard_key(device, KEY_Q, true);
@ -2147,6 +2183,7 @@ MUNIT_TEST(test_passive_ei_frame_timestamp)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
_unref_(ei_event) *kbd1 =
peck_ei_next_event(ei, EI_EVENT_KEYBOARD_KEY);
_unref_(ei_event) *frame1 =
@ -2184,9 +2221,11 @@ MUNIT_TEST(test_passive_ei_flush_frame)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
uint32_t sequence = 678;
with_server(peck) {
struct eis_device *device = peck_eis_get_default_keyboard(peck);
eis_device_start_emulating(device);
eis_device_start_emulating(device, sequence);
eis_device_keyboard_key(device, KEY_Q, true);
/* Missing call to ei_device_frame() */
eis_device_stop_emulating(device);
@ -2197,6 +2236,7 @@ MUNIT_TEST(test_passive_ei_flush_frame)
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
munit_assert_uint(ei_event_emulating_get_sequence(start), ==, sequence);
_unref_(ei_event) *kbd =
peck_ei_next_event(ei, EI_EVENT_KEYBOARD_KEY);
_unref_(ei_event) *frame =

View file

@ -323,6 +323,8 @@ MUNIT_TEST(eistest_device_ignore_paused_device)
}
uint32_t sequence = 100;
for (size_t i = 0; i < 3; i++) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
@ -341,7 +343,7 @@ MUNIT_TEST(eistest_device_ignore_paused_device)
struct ei_device *device = ei_event_get_device(resumed);
peck_assert_no_ei_events(ei);
with_emulation(device) {
with_emulation(device, ++sequence) {
ei_device_pointer_motion(device, 1, 1);
}
}

View file

@ -286,6 +286,8 @@ int main(int argc, char **argv)
bool have_abs = false;
struct ei_seat *default_seat = NULL;
uint32_t sequence = 0;
while (!stop && poll(&fds, 1, 2000) > -1) {
ei_dispatch(ei);
@ -347,19 +349,19 @@ int main(int argc, char **argv)
case EI_EVENT_DEVICE_RESUMED:
if (ei_event_get_device(e) == ptr) {
if (!receiver)
ei_device_start_emulating(ptr);
ei_device_start_emulating(ptr, ++sequence);
colorprint("Pointer device was resumed\n");
have_ptr = true;
}
if (ei_event_get_device(e) == kbd) {
if (!receiver)
ei_device_start_emulating(kbd);
ei_device_start_emulating(kbd, ++sequence);
colorprint("Keyboard device was resumed\n");
have_kbd = true;
}
if (ei_event_get_device(e) == abs) {
if (!receiver)
ei_device_start_emulating(abs);
ei_device_start_emulating(abs, ++sequence);
colorprint("Abs pointer device was resumed\n");
have_abs = true;
}

View file

@ -202,6 +202,8 @@ static struct eis_device *
add_device(struct eis_demo_server *server, struct eis_client *client,
struct eis_seat *seat, enum eis_device_capability cap)
{
static uint32_t sequence;
struct eis_device *device = NULL;
switch (cap) {
case EIS_DEVICE_CAP_POINTER:
@ -218,7 +220,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_device_add(ptr);
eis_device_resume(ptr);
if (!eis_client_is_sender(client))
eis_device_start_emulating(ptr);
eis_device_start_emulating(ptr, ++sequence);
device = steal(&ptr);
break;
}
@ -236,7 +238,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_device_add(abs);
eis_device_resume(abs);
if (!eis_client_is_sender(client))
eis_device_start_emulating(abs);
eis_device_start_emulating(abs, ++sequence);
device = steal(&abs);
break;
}
@ -252,7 +254,7 @@ add_device(struct eis_demo_server *server, struct eis_client *client,
eis_device_add(kbd);
eis_device_resume(kbd);
if (!eis_client_is_sender(client))
eis_device_start_emulating(kbd);
eis_device_start_emulating(kbd, ++sequence);
device = steal(&kbd);
break;
}