mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-07 06:30:15 +01:00
proto: split the client's SetProperty from the server event
This makes the code/protocol slightly more readable.
This commit is contained in:
parent
0a382dec3d
commit
07f80cc002
8 changed files with 38 additions and 31 deletions
|
|
@ -163,7 +163,7 @@ message Frame {
|
|||
uint64 timestamp = 2;
|
||||
}
|
||||
|
||||
message Property {
|
||||
message SetProperty {
|
||||
string name = 1;
|
||||
string value = 2;
|
||||
uint32 permissions = 3;
|
||||
|
|
@ -177,7 +177,7 @@ message ClientMessage {
|
|||
Disconnect disconnect = 3;
|
||||
BindSeat bind_seat = 4;
|
||||
CloseDevice close_device = 6;
|
||||
Property property = 9;
|
||||
SetProperty set_property = 9;
|
||||
|
||||
/* Events */
|
||||
StartEmulating start_emulating = 20;
|
||||
|
|
@ -206,6 +206,12 @@ message Connected {
|
|||
message Disconnected {
|
||||
}
|
||||
|
||||
message Property {
|
||||
string name = 1;
|
||||
string value = 2;
|
||||
uint32 permissions = 3;
|
||||
}
|
||||
|
||||
message SeatAdded {
|
||||
uint32 seatid = 1;
|
||||
uint32 capabilities = 2;
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error)
|
|||
MSG_STRING_CASE(DISCONNECT);
|
||||
MSG_STRING_CASE(BIND_SEAT);
|
||||
MSG_STRING_CASE(CLOSE_DEVICE);
|
||||
MSG_STRING_CASE(PROPERTY);
|
||||
MSG_STRING_CASE(SET_PROPERTY);
|
||||
/* events */
|
||||
MSG_STRING_CASE(START_EMULATING);
|
||||
MSG_STRING_CASE(STOP_EMULATING);
|
||||
|
|
@ -526,13 +526,14 @@ ei_proto_send_frame(struct ei_device *device, uint64_t time)
|
|||
}
|
||||
|
||||
static int
|
||||
ei_proto_send_property(struct ei *ei, const char *name, const char *value, uint32_t permissions)
|
||||
ei_proto_send_set_property(struct ei *ei, const char *name,
|
||||
const char *value, uint32_t permissions)
|
||||
{
|
||||
prepare_msg(PROPERTY, Property, property);
|
||||
prepare_msg(SET_PROPERTY, SetProperty, set_property);
|
||||
|
||||
property.name = (char*)name;
|
||||
property.value = value ? (char*)value : "";
|
||||
property.permissions = permissions;
|
||||
set_property.name = (char*)name;
|
||||
set_property.value = value ? (char*)value : "";
|
||||
set_property.permissions = permissions;
|
||||
|
||||
return ei_proto_send_msg(ei, &msg);
|
||||
}
|
||||
|
|
@ -542,7 +543,7 @@ static const struct ei_proto_requests requests = {
|
|||
.connect_done = ei_proto_send_connect_done,
|
||||
.disconnect = ei_proto_send_disconnect,
|
||||
.bind_seat = ei_proto_send_bind_seat,
|
||||
.property = ei_proto_send_property,
|
||||
.set_property = ei_proto_send_set_property,
|
||||
.close_device = ei_proto_send_close_device,
|
||||
|
||||
/* events */
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ struct ei_proto_requests {
|
|||
uint32_t tid, double x, double y);
|
||||
int (*touch_up)(struct ei_device *device, uint32_t tid);
|
||||
int (*frame)(struct ei_device *device, uint64_t time);
|
||||
int (*property)(struct ei *ei,
|
||||
const char *name, const char *value,
|
||||
uint32_t permissions);
|
||||
int (*set_property)(struct ei *ei,
|
||||
const char *name, const char *value,
|
||||
uint32_t permissions);
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ ei_send_property(struct ei *ei, const char *name, const char *value, uint32_t pe
|
|||
if (ei->state == EI_STATE_NEW || ei->state == EI_STATE_DISCONNECTED)
|
||||
return 0;
|
||||
|
||||
int rc = ei->requests->property(ei, name, value, permissions);
|
||||
int rc = ei->requests->set_property(ei, name, value, permissions);
|
||||
if (rc)
|
||||
ei_disconnect(ei);
|
||||
return rc;
|
||||
|
|
@ -1429,7 +1429,7 @@ ei_set_connection(struct ei *ei, int fd)
|
|||
struct ei_property *prop;
|
||||
list_for_each_safe(prop, &ei->properties, link) {
|
||||
if (rc == 0)
|
||||
rc = ei->requests->property(ei, prop->name, prop->value, prop->permissions);
|
||||
rc = ei->requests->set_property(ei, prop->name, prop->value, prop->permissions);
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
|
|
|
|||
|
|
@ -540,9 +540,9 @@ client_msg_disconnect(struct eis_client *client)
|
|||
}
|
||||
|
||||
static int
|
||||
client_msg_property(struct eis_client *client,
|
||||
const char *name, const char *value,
|
||||
uint32_t permissions)
|
||||
client_msg_set_property(struct eis_client *client,
|
||||
const char *name, const char *value,
|
||||
uint32_t permissions)
|
||||
{
|
||||
eis_property_update_from_client(client, name, value, permissions);
|
||||
|
||||
|
|
@ -550,11 +550,11 @@ client_msg_property(struct eis_client *client,
|
|||
}
|
||||
|
||||
static int
|
||||
client_msg_property_with_event(struct eis_client *client,
|
||||
client_msg_set_property_with_event(struct eis_client *client,
|
||||
const char *name, const char *value,
|
||||
uint32_t permissions)
|
||||
{
|
||||
int rc = client_msg_property(client, name, value, permissions);
|
||||
int rc = client_msg_set_property(client, name, value, permissions);
|
||||
if (rc == 0)
|
||||
eis_queue_property_event(client, name, value, permissions);
|
||||
return rc;
|
||||
|
|
@ -562,7 +562,7 @@ client_msg_property_with_event(struct eis_client *client,
|
|||
|
||||
static const struct eis_proto_interface intf_state_new = {
|
||||
.connect = client_msg_connect,
|
||||
.property = client_msg_property,
|
||||
.set_property = client_msg_set_property,
|
||||
.connect_done = client_msg_connect_done,
|
||||
.disconnect = client_msg_disconnect,
|
||||
|
||||
|
|
@ -580,7 +580,7 @@ static const struct eis_proto_interface intf_state_connecting = {
|
|||
|
||||
static const struct eis_proto_interface intf_state_connected = {
|
||||
.disconnect = client_msg_disconnect,
|
||||
.property = client_msg_property_with_event,
|
||||
.set_property = client_msg_set_property_with_event,
|
||||
.bind_seat = client_msg_bind_seat,
|
||||
.close_device = client_msg_close_device,
|
||||
|
||||
|
|
|
|||
|
|
@ -529,10 +529,10 @@ eis_proto_handle_message(struct eis_client *client,
|
|||
rc = call(close_device, client,
|
||||
proto->close_device->deviceid);
|
||||
break;
|
||||
case CLIENT_MESSAGE__MSG_PROPERTY:
|
||||
rc = call(property, client, proto->property->name,
|
||||
proto->property->value[0] ? proto->property->value : NULL,
|
||||
proto->property->permissions);
|
||||
case CLIENT_MESSAGE__MSG_SET_PROPERTY:
|
||||
rc = call(set_property, client, proto->set_property->name,
|
||||
proto->set_property->value[0] ? proto->set_property->value : NULL,
|
||||
proto->set_property->permissions);
|
||||
break;
|
||||
/* Events */
|
||||
case CLIENT_MESSAGE__MSG_START_EMULATING:
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ struct eis_proto_interface {
|
|||
int (*bind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap);
|
||||
int (*unbind_seat)(struct eis_client *client, uint32_t seatid, enum eis_device_capability cap);
|
||||
int (*close_device)(struct eis_client *client, uint32_t deviceid);
|
||||
int (*property)(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
int (*set_property)(struct eis_client *client, const char *name,
|
||||
const char *value, uint32_t permissions);
|
||||
/* events */
|
||||
int (*start_emulating)(struct eis_client *client, uint32_t deviceid);
|
||||
int (*stop_emulating)(struct eis_client *client, uint32_t deviceid);
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ reis_set_property_with_permissions(struct reis *reis,
|
|||
const char *name, const char *value,
|
||||
uint32_t permissions)
|
||||
{
|
||||
prepare_msg(PROPERTY, Property, property);
|
||||
prepare_msg(SET_PROPERTY, SetProperty, set_property);
|
||||
|
||||
property.name = (char*)name;
|
||||
property.value = value ? (char*)value : "";
|
||||
property.permissions = permissions;
|
||||
set_property.name = (char*)name;
|
||||
set_property.value = value ? (char*)value : "";
|
||||
set_property.permissions = permissions;
|
||||
|
||||
return send_msg(reis->eisfd, &msg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue