eis: the EIS context does not have a is_active setting

This is a leftover from an earlier implementation that didn't get
removed in time. This extends to a macro that was using the context flag
(rather than the client flag) and in turn caused a bunch of false
positives on the tests.
This commit is contained in:
Peter Hutterer 2022-03-28 16:09:52 +10:00
parent 42c1a69436
commit 7b760e5950
9 changed files with 140 additions and 45 deletions

View file

@ -196,7 +196,6 @@ message Connected {
}
message Disconnected {
bool is_active = 2;
}
message SeatAdded {

View file

@ -64,7 +64,7 @@ ei_proto_handle_message(struct ei *ei,
rc = call(connected, ei);
break;
case SERVER_MESSAGE__MSG_DISCONNECTED:
rc = call(disconnected, ei, proto->disconnected->is_active);
rc = call(disconnected, ei);
break;
case SERVER_MESSAGE__MSG_SEAT_ADDED:
rc = call(seat_added, ei,

View file

@ -35,7 +35,7 @@
/* callbacks invoked during ei_proto_parse_message() */
struct ei_proto_interface {
int (*connected)(struct ei *ei);
int (*disconnected)(struct ei *ei, bool is_active);
int (*disconnected)(struct ei *ei);
int (*seat_added)(struct ei *ei, uint32_t seatid,
const char *name, uint32_t capabilities);
int (*seat_removed)(struct ei *ei, uint32_t seatid);

View file

@ -1035,12 +1035,7 @@ static int handle_msg_connected(struct ei *ei) {
return 0;
}
static int handle_msg_disconnected(struct ei *ei, bool is_active) {
if (ei->is_active == is_active) {
log_bug_client(ei, "Unable to connect %s ei context to %s EIS implementation\n",
is_active ? "active" : "passive",
is_active ? "active" : "passive");
}
static int handle_msg_disconnected(struct ei *ei) {
return -ECANCELED;
}

View file

@ -275,8 +275,8 @@ client_msg_unbind_seat(struct eis_client *client, uint32_t seatid)
}
#define DISCONNECT_IF_ACTIVE_CONTEXT(client_) do { \
struct eis *_ctx = eis_client_get_context(client_); \
if (_ctx->is_active) { \
if (!(client_)->is_active) { \
struct eis *_ctx = eis_client_get_context(client_); \
log_bug_client(_ctx, "Invalid event from passive ei context. Disconnecting client\n"); \
return -EINVAL; \
} \

View file

@ -54,8 +54,6 @@ struct eis {
} log;
const struct eis_proto_requests *requests;
bool is_active;
};
enum eis_client_state {

View file

@ -132,10 +132,7 @@ eis_proto_send_msg_with_fds(struct eis_client *client, const ServerMessage *msg,
static int
eis_proto_send_disconnected(struct eis_client *client)
{
struct eis *eis = eis_client_get_context(client);
prepare_msg(DISCONNECTED, Disconnected, disconnected);
disconnected.is_active = eis->is_active;
return eis_proto_send_msg(client, &msg);
}

View file

@ -837,7 +837,8 @@ _peck_dispatch_ei(struct peck *peck, int lineno)
case EI_EVENT_DEVICE_RESUMED:
if (flag_is_set(peck->ei_behavior, PECK_EI_BEHAVIOR_AUTOSTART)) {
struct ei_device *device = ei_event_get_device(e);
ei_device_start_emulating(device);
if (ei_is_active(ei_device_get_context(device)))
ei_device_start_emulating(device);
}
break;
case EI_EVENT_DEVICE_PAUSED:

View file

@ -1186,6 +1186,18 @@ MUNIT_TEST(test_passive_ei_device_keyboard_key)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_keyboard(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
struct eis_device *device = peck_eis_get_default_keyboard(peck);
eis_device_keyboard_key(device, KEY_Q, true);
@ -1221,6 +1233,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_rel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_pointer_motion(device, 1, 2);
@ -1264,6 +1288,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_abs)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer_absolute(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
device = peck_eis_get_default_pointer_absolute(peck);
@ -1332,6 +1368,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_pointer_scroll(device, 1.1, 2.2);
@ -1367,6 +1415,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_pointer_scroll(device, 1.1, 2.2);
@ -1437,6 +1497,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_cancel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_pointer_scroll(device, 1.1, 2.2);
@ -1507,6 +1579,18 @@ MUNIT_TEST(test_passive_ei_device_pointer_scroll_stop_cancel)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
/* cancel after stop is fine, stop after cancel is ignored */
with_server(peck) {
struct eis_device *device = peck_eis_get_default_pointer(peck);
@ -1568,6 +1652,18 @@ MUNIT_TEST(test_passive_ei_device_touch)
peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES);
peck_dispatch_until_stable(peck);
with_server(peck) {
device = peck_eis_get_default_touch(peck);
eis_device_start_emulating(device);
}
peck_dispatch_until_stable(peck);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
}
with_server(peck) {
device = peck_eis_get_default_touch(peck);
/* We know our default device has one region */
@ -1576,6 +1672,8 @@ 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);
_unref_(eis_touch) *t = eis_device_touch_new(device);
eis_touch_down(t, 1, 2);
eis_device_frame(device);
@ -1731,7 +1829,6 @@ MUNIT_TEST(test_passive_ei_device_touch)
MUNIT_TEST(test_passive_ei_device_multitouch)
{
_unref_(peck) *peck = peck_new_context(PECK_EI_PASSIVE);
struct ei_device *device = NULL;
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL);
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ADD_TOUCH);
@ -1740,45 +1837,53 @@ MUNIT_TEST(test_passive_ei_device_multitouch)
peck_dispatch_until_stable(peck);
with_client(peck) {
device = peck_ei_get_default_touch(peck);
_unref_(ei_touch) *t1 = ei_device_touch_new(device);
_unref_(ei_touch) *t2 = ei_device_touch_new(device);
ei_touch_down(t1, 1, 2);
ei_device_frame(device);
ei_touch_motion(t1, 2, 3);
ei_device_frame(device);
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_touch_down(t1, 1, 2);
eis_device_frame(device);
eis_touch_motion(t1, 2, 3);
eis_device_frame(device);
ei_touch_down(t2, 3, 4);
ei_device_frame(device);
ei_touch_motion(t2, 4, 5);
ei_device_frame(device);
eis_touch_down(t2, 3, 4);
eis_device_frame(device);
eis_touch_motion(t2, 4, 5);
eis_device_frame(device);
ei_touch_up(t2);
ei_touch_up(t1);
eis_touch_up(t2);
eis_touch_up(t1);
eis_device_stop_emulating(device);
}
peck_dispatch_until_stable(peck);
with_server(peck) {
_unref_(eis_event) *down1 = peck_eis_touch_down(eis, 1, 2);
uint32_t tid1 = eis_event_touch_get_id(down1);
with_client(peck) {
_unref_(ei_event) *start =
peck_ei_next_event(ei, EI_EVENT_DEVICE_START_EMULATING);
_unref_(eis_event) *motion1 = peck_eis_touch_motion(eis, 2, 3);
munit_assert_uint32(eis_event_touch_get_id(motion1), ==, tid1);
_unref_(ei_event) *down1 = peck_ei_touch_down(ei, 1, 2);
uint32_t tid1 = ei_event_touch_get_id(down1);
_unref_(eis_event) *down2 = peck_eis_touch_down(eis, 3, 4);
uint32_t tid2 = eis_event_touch_get_id(down2);
_unref_(ei_event) *motion1 = peck_ei_touch_motion(ei, 2, 3);
munit_assert_uint32(ei_event_touch_get_id(motion1), ==, tid1);
_unref_(ei_event) *down2 = peck_ei_touch_down(ei, 3, 4);
uint32_t tid2 = ei_event_touch_get_id(down2);
munit_assert_uint32(tid2, !=, tid1);
_unref_(eis_event) *motion2 = peck_eis_touch_motion(eis, 4, 5);
munit_assert_uint32(eis_event_touch_get_id(motion2), ==, tid2);
_unref_(ei_event) *motion2 = peck_ei_touch_motion(ei, 4, 5);
munit_assert_uint32(ei_event_touch_get_id(motion2), ==, tid2);
_unref_(eis_event) *up2 = peck_eis_touch_up(eis);
munit_assert_uint32(eis_event_touch_get_id(up2), ==, tid2);
_unref_(ei_event) *up2 = peck_ei_touch_up(ei);
munit_assert_uint32(ei_event_touch_get_id(up2), ==, tid2);
_unref_(eis_event) *up1 = peck_eis_touch_up(eis);
munit_assert_uint32(eis_event_touch_get_id(up1), ==, tid1);
_unref_(ei_event) *up1 = peck_ei_touch_up(ei);
munit_assert_uint32(ei_event_touch_get_id(up1), ==, tid1);
_unref_(ei_event) *stop =
peck_ei_next_event(ei, EI_EVENT_DEVICE_STOP_EMULATING);
}
return MUNIT_OK;