eis: after the client binds the seat, drop the capabilities

This way eis_seat_has_capability() returns the effective capabilities
the server can actually use - no point creating touch devices when the
client has not confirmed that.

In theory we should have a eis_seat_get_effective_capabilities() to
differ between configured and effective capabilities, but I'm having a
hard time thinking of a use-case where the implementation forgets
which caps it enabled.

The side-effect of this patch is that adding a device without
capabilities requested by the client now produces warning.
This commit is contained in:
Peter Hutterer 2022-03-07 11:18:47 +10:00
parent c012579c51
commit a5e6af5bff
2 changed files with 18 additions and 0 deletions

View file

@ -122,6 +122,7 @@ eis_seat_bind(struct eis_seat *seat, uint32_t caps)
}
seat->state = EIS_SEAT_STATE_BOUND;
seat->capabilities_mask &= caps;
eis_queue_seat_bind_event(seat, caps);
}

View file

@ -116,6 +116,15 @@ MUNIT_TEST(eistest_cliend_bind_some_caps)
peck_dispatch_until_stable(peck);
/* Before the clients binds to the seat, our seat has all caps */
with_server(peck) {
struct eis_seat *seat = peck_eis_get_default_seat(peck);
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_KEYBOARD));
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_POINTER));
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_POINTER_ABSOLUTE));
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_TOUCH));
}
with_client(peck) {
_unref_(ei_event) *event =
peck_ei_next_event(ei, EI_EVENT_SEAT_ADDED);
@ -140,6 +149,14 @@ MUNIT_TEST(eistest_cliend_bind_some_caps)
munit_assert_true(eis_event_seat_has_capability(event, EIS_DEVICE_CAP_POINTER));
munit_assert_true(eis_event_seat_has_capability(event, EIS_DEVICE_CAP_POINTER_ABSOLUTE));
munit_assert_false(eis_event_seat_has_capability(event, EIS_DEVICE_CAP_TOUCH));
/* Now that the client bound the seat with a subset, our
eis seat has a subset too */
struct eis_seat *seat = peck_eis_get_default_seat(peck);
munit_assert_false(eis_seat_has_capability(seat, EIS_DEVICE_CAP_KEYBOARD));
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_POINTER));
munit_assert_true(eis_seat_has_capability(seat, EIS_DEVICE_CAP_POINTER_ABSOLUTE));
munit_assert_false(eis_seat_has_capability(seat, EIS_DEVICE_CAP_TOUCH));
}
return MUNIT_OK;