mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-03 02:10:11 +01:00
libei: add a few comments and extra checks
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
b5f1082419
commit
6dc848b2c3
3 changed files with 14 additions and 1 deletions
|
|
@ -46,6 +46,7 @@ OBJECT_IMPLEMENT_PARENT(ei_device, ei);
|
|||
_public_ struct ei*
|
||||
ei_device_get_context(struct ei_device *device)
|
||||
{
|
||||
assert(device);
|
||||
return ei_device_parent(device);
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +54,8 @@ _public_
|
|||
struct ei_device *
|
||||
ei_device_new(struct ei *ei)
|
||||
{
|
||||
/* device IDs are managed by the client, the server merely accepts
|
||||
* them and fails where they're being reused. */
|
||||
static uint32_t deviceid = 0;
|
||||
struct ei_device *device = ei_device_create(&ei->object);
|
||||
|
||||
|
|
@ -67,6 +70,9 @@ _public_ bool
|
|||
ei_device_configure_capability(struct ei_device *device,
|
||||
enum ei_device_capability cap)
|
||||
{
|
||||
if (device->state != EI_DEVICE_STATE_NEW)
|
||||
return false;
|
||||
|
||||
switch (cap) {
|
||||
case EI_DEVICE_CAP_POINTER:
|
||||
case EI_DEVICE_CAP_POINTER_ABSOLUTE:
|
||||
|
|
@ -83,6 +89,7 @@ _public_ void
|
|||
ei_device_add(struct ei_device *device)
|
||||
{
|
||||
ei_add_device(device);
|
||||
device->state = EI_DEVICE_STATE_CONNECTING;
|
||||
}
|
||||
|
||||
_public_ void
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ struct ei {
|
|||
|
||||
enum ei_device_state {
|
||||
EI_DEVICE_STATE_NEW,
|
||||
EI_DEVICE_STATE_CONNECTING,
|
||||
EI_DEVICE_STATE_ACCEPTED,
|
||||
EI_DEVICE_STATE_REMOVED,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ message_free(struct message *msg)
|
|||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct message*, message_free);
|
||||
|
||||
|
||||
static struct ei_event* ei_event_ref(struct ei_event *event);
|
||||
|
||||
static void
|
||||
|
|
@ -700,6 +699,12 @@ ei_set_connection(struct ei *ei, int fd)
|
|||
_public_ void
|
||||
ei_configure_name(struct ei *ei, const char *name)
|
||||
{
|
||||
if (ei->state != EI_STATE_NEW)
|
||||
return;
|
||||
|
||||
if (strlen(name) > 1024)
|
||||
return;
|
||||
|
||||
free(ei->name);
|
||||
ei->name = xstrdup(name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue