mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-10 09:10:17 +01:00
libei: handle a late device connect correctly
Where the server connects a device after the client has already removed it, we need to ignore that message silently. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
689e5c4ed9
commit
91c4bc2a93
2 changed files with 53 additions and 2 deletions
|
|
@ -355,8 +355,10 @@ ei_added(struct ei *ei, uint32_t deviceid, uint32_t capabilities)
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: could be a device since removed by the client */
|
||||
return -EBADMSG;
|
||||
/* Wrong device id or a device already removed by the client but we
|
||||
* won't know which unless we keep some device ID table. Not worth
|
||||
* it, so just silently ignore */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -250,6 +250,55 @@ MUNIT_TEST(eistest_device_ignore_suspended)
|
|||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
MUNIT_TEST(eistest_device_late_connect)
|
||||
{
|
||||
_cleanup_peck_ struct peck *peck = peck_new();
|
||||
_cleanup_eis_device_ struct eis_device *eis_device = NULL;
|
||||
_cleanup_ei_device_ struct ei_device *ei_device = NULL;
|
||||
|
||||
peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_CLIENT);
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
ei_device = ei_device_new(ei);
|
||||
ei_device_configure_capability(ei_device, EI_DEVICE_CAP_POINTER);
|
||||
ei_device_add(ei_device);
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
_cleanup_eis_event_ struct eis_event *added =
|
||||
peck_eis_next_event(eis, EIS_EVENT_DEVICE_ADDED);
|
||||
eis_device = eis_device_ref(eis_event_get_device(added));
|
||||
/* Do not connect here */
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_client(peck) {
|
||||
ei_device_remove(ei_device);
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
eis_device_connect(eis_device);
|
||||
}
|
||||
|
||||
peck_dispatch_until_stable(peck);
|
||||
|
||||
with_server(peck) {
|
||||
peck_assert_no_eis_events(eis);
|
||||
}
|
||||
|
||||
with_client(peck) {
|
||||
peck_assert_no_ei_events(ei);
|
||||
}
|
||||
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue