mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 01:10:25 +01:00
path: split out creating a device into a helper function
No functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
8d24cd5304
commit
5f703f48b0
1 changed files with 32 additions and 25 deletions
57
src/path.c
57
src/path.c
|
|
@ -236,6 +236,37 @@ path_input_destroy(struct libinput *input)
|
|||
|
||||
}
|
||||
|
||||
static struct libinput_device *
|
||||
path_create_device(struct libinput *libinput,
|
||||
const char *path)
|
||||
{
|
||||
struct path_input *input = (struct path_input*)libinput;
|
||||
struct path_device *dev;
|
||||
struct libinput_device *device;
|
||||
|
||||
dev = zalloc(sizeof *dev);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
dev->path = strdup(path);
|
||||
if (!dev->path) {
|
||||
free(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list_insert(&input->path_list, &dev->link);
|
||||
|
||||
device = path_device_enable(input, dev->path);
|
||||
|
||||
if (!device) {
|
||||
list_remove(&dev->link);
|
||||
free(dev->path);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
static const struct libinput_interface_backend interface_backend = {
|
||||
.resume = path_input_enable,
|
||||
.suspend = path_input_disable,
|
||||
|
|
@ -275,36 +306,12 @@ LIBINPUT_EXPORT struct libinput_device *
|
|||
libinput_path_add_device(struct libinput *libinput,
|
||||
const char *path)
|
||||
{
|
||||
struct path_input *input = (struct path_input*)libinput;
|
||||
struct path_device *dev;
|
||||
struct libinput_device *device;
|
||||
|
||||
if (libinput->interface_backend != &interface_backend) {
|
||||
log_bug_client(libinput, "Mismatching backends.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dev = zalloc(sizeof *dev);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
dev->path = strdup(path);
|
||||
if (!dev->path) {
|
||||
free(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list_insert(&input->path_list, &dev->link);
|
||||
|
||||
device = path_device_enable(input, dev->path);
|
||||
|
||||
if (!device) {
|
||||
list_remove(&dev->link);
|
||||
free(dev->path);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
return device;
|
||||
return path_create_device(libinput, path);
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue