Commit 1d697d7a authored by Rob Bradford's avatar Rob Bradford Committed by Kristian H. Kristensen

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.
parent 8f7f4836
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment