eis: only allow the available caps to bind to a seat

A client binding with caps >= the seat's current version will get
disconnected now.
This commit is contained in:
Peter Hutterer 2023-02-10 16:04:24 +10:00
parent ea8df6402a
commit b481eff34c

View file

@ -90,6 +90,20 @@ client_msg_release(struct eis_seat *seat)
static int
client_msg_bind(struct eis_seat *seat, uint32_t caps)
{
uint32_t allowed_caps = 0;
if (seat->proto_object.version >= EIS_SEAT_CAPABILITIES_POINTER_SINCE_VERSION)
allowed_caps |= EIS_SEAT_CAPABILITIES_POINTER;
if (seat->proto_object.version >= EIS_SEAT_CAPABILITIES_POINTER_ABSOLUTE_SINCE_VERSION)
allowed_caps |= EIS_SEAT_CAPABILITIES_POINTER_ABSOLUTE;
if (seat->proto_object.version >= EIS_SEAT_CAPABILITIES_KEYBOARD_SINCE_VERSION)
allowed_caps |= EIS_SEAT_CAPABILITIES_KEYBOARD;
if (seat->proto_object.version >= EIS_SEAT_CAPABILITIES_TOUCHSCREEN_SINCE_VERSION)
allowed_caps |= EIS_SEAT_CAPABILITIES_TOUCHSCREEN;
if (caps & ~allowed_caps)
return -EINVAL;
eis_seat_bind(seat, caps);
return 0;