protocol: move the seat bind to the seat object

Needs documentation but we can do this when we're done with everything.
This commit is contained in:
Peter Hutterer 2023-02-03 16:14:28 +10:00
parent b9037ed4ff
commit 2a8661f7ad
6 changed files with 40 additions and 58 deletions

View file

@ -86,11 +86,6 @@
<request name="disconnect">
</request>
<request name="bind_seat">
<arg name="seat_id" type="uint"/>
<arg name="capabilities" type="uint"/>
</request>
<request name="close_device">
<arg name="device_id" type="uint"/>
</request>
@ -447,6 +442,20 @@
</description>
</request>
<enum name="capabilities" since="1">
<entry name="pointer" value="2"/>
<entry name="pointer_absolute" value="4"/>
<entry name="keyboard" value="8"/>
<entry name="touch" value="16"/>
</enum>
<request name="bind">
<description summary="Seat binding">
Bind to the bitmask of capabilities given.
</description>
<arg name="capabilities" type="uint"/>
</request>
<event name="destroyed" since="1">
<description summary="Seat removal notification">
This seat has been removed and a client should release all
@ -462,13 +471,6 @@
<arg name="name" type="string" help="the seat name"/>
</event>
<enum name="capabilities" since="1">
<entry name="pointer" value="2"/>
<entry name="pointer_absolute" value="4"/>
<entry name="keyboard" value="8"/>
<entry name="touch" value="16"/>
</enum>
<event name="capabilities" since="1">
<description summary="Seat capability notification">
A bitmask of the capabilities of this seat.

View file

@ -114,9 +114,6 @@ ei_send_message(struct ei *ei, uint32_t object_id,
void
ei_add_seat(struct ei_seat *seat);
int
ei_send_seat_bind(struct ei_seat *seat, uint32_t capabilities);
int
ei_send_close_device(struct ei_device *device);

View file

@ -226,6 +226,20 @@ is_known_cap(enum ei_device_capability cap)
return false;
}
static int
ei_seat_send_bind(struct ei_seat *seat, uint32_t capabilities)
{
struct ei *ei = ei_seat_get_context(seat);
if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED)
return 0;
int rc = ei_seat_request_bind(seat, capabilities);
if (rc)
ei_disconnect(ei);
return rc;
}
_public_ void
ei_seat_bind_capabilities(struct ei_seat *seat, ...)
{
@ -255,7 +269,7 @@ ei_seat_bind_capabilities(struct ei_seat *seat, ...)
return;
seat->capabilities_bound = mask;
ei_send_seat_bind(seat, seat->capabilities_bound);
ei_seat_send_bind(seat, seat->capabilities_bound);
}
_public_ void
@ -280,7 +294,7 @@ ei_seat_unbind_capability(struct ei_seat *seat,
if (ei_device_has_capability(device, cap))
ei_device_close(device);
}
ei_send_seat_bind(seat, seat->capabilities_bound);
ei_seat_send_bind(seat, seat->capabilities_bound);
}
_public_ void
@ -312,5 +326,5 @@ ei_seat_unbind_capabilities(struct ei_seat *seat, ...)
return;
seat->capabilities_bound = mask;
ei_send_seat_bind(seat, seat->capabilities_bound);
ei_seat_send_bind(seat, seat->capabilities_bound);
}

View file

@ -858,20 +858,6 @@ ei_send_stop_emulating(struct ei_device *device)
return rc;
}
int
ei_send_seat_bind(struct ei_seat *seat, uint32_t capabilities)
{
struct ei *ei = ei_seat_get_context(seat);
if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED)
return 0;
int rc = ei_connection_request_bind_seat(ei->connection, ei_seat_get_id(seat), capabilities);
if (rc)
ei_disconnect(ei);
return rc;
}
int
ei_send_frame(struct ei_device *device, uint64_t time)
{

View file

@ -157,19 +157,6 @@ eis_client_find_device(struct eis_client *client, uint32_t deviceid)
return NULL;
}
static struct eis_seat *
eis_client_find_seat(struct eis_client *client, uint32_t seatid)
{
struct eis_seat *seat;
list_for_each(seat, &client->seats, link) {
if (eis_seat_get_id(seat) == seatid)
return seat;
}
return NULL;
}
int
eis_client_send_message(struct eis_client *client, uint32_t object_id,
uint32_t opcode, const char *signature, size_t nargs, ...)
@ -334,18 +321,6 @@ client_msg_close_device(struct eis_connection *connection, uint32_t deviceid)
return 0;
}
static int
client_msg_bind_seat(struct eis_connection *connection, uint32_t seatid, uint32_t caps)
{
struct eis_client *client = eis_connection_get_client(connection);
struct eis_seat *seat = eis_client_find_seat(client, seatid);
if (seat)
eis_seat_bind(seat, caps);
return seat ? 0 : -EINVAL;
}
#define DISCONNECT_IF_RECEIVER_CONTEXT(client_) do { \
if (!(client_)->is_sender) { \
struct eis *_ctx = eis_client_get_context(client_); \
@ -598,7 +573,6 @@ static const struct eis_connection_interface intf_state_connecting = {
static const struct eis_connection_interface intf_state_connected = {
.sync = client_msg_sync,
.disconnect = client_msg_disconnect,
.bind_seat = client_msg_bind_seat,
.close_device = client_msg_close_device,
/* events */

View file

@ -87,8 +87,17 @@ client_msg_release(struct eis_seat *seat)
return 0;
}
static int
client_msg_bind(struct eis_seat *seat, uint32_t caps)
{
eis_seat_bind(seat, caps);
return 0;
}
static const struct eis_seat_interface interface = {
.release = client_msg_release,
.bind = client_msg_bind,
};
const struct eis_seat_interface *