mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 12:10:06 +01:00
udev-seat: Refactor out seat lookup and possible creation
This change spills the code for looking up a seat by name and then potentially creating it if it doesn't exist into a new function called udev_seat_get_named. This change allows us to reuse this code when looking up the seat when parsing seat constraints per output.
This commit is contained in:
parent
0a375ebb38
commit
e2da4d888c
2 changed files with 22 additions and 9 deletions
|
|
@ -66,18 +66,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input)
|
|||
if (!seat_name)
|
||||
seat_name = default_seat_name;
|
||||
|
||||
wl_list_for_each(seat, &c->seat_list, base.link) {
|
||||
if (strcmp(seat->base.seat_name, seat_name) == 0)
|
||||
goto seat_found;
|
||||
}
|
||||
seat = udev_seat_get_named(c, seat_name);
|
||||
|
||||
seat = udev_seat_create(c, seat_name);
|
||||
|
||||
if (!seat)
|
||||
if (seat == NULL)
|
||||
return -1;
|
||||
|
||||
seat_found:
|
||||
|
||||
/* Use non-blocking mode so that we can loop on read on
|
||||
* evdev_device_data() until all events on the fd are
|
||||
* read. mtdev_get() also expects this. */
|
||||
|
|
@ -350,3 +343,21 @@ udev_seat_destroy(struct udev_seat *seat)
|
|||
weston_seat_release(&seat->base);
|
||||
free(seat);
|
||||
}
|
||||
|
||||
struct udev_seat *
|
||||
udev_seat_get_named(struct weston_compositor *c, const char *seat_name)
|
||||
{
|
||||
struct udev_seat *seat;
|
||||
|
||||
wl_list_for_each(seat, &c->seat_list, base.link) {
|
||||
if (strcmp(seat->base.seat_name, seat_name) == 0)
|
||||
return seat;
|
||||
}
|
||||
|
||||
seat = udev_seat_create(c, seat_name);
|
||||
|
||||
if (!seat)
|
||||
return NULL;
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,6 @@ int udev_input_init(struct udev_input *input,
|
|||
const char *seat_id);
|
||||
void udev_input_destroy(struct udev_input *input);
|
||||
|
||||
struct udev_seat *udev_seat_get_named(struct weston_compositor *c,
|
||||
const char *seat_name);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue