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.
dev
Rob Bradford 12 years ago committed by Kristian Høgsberg
parent 8f7f483668
commit 1d697d7adf
  1. 29
      src/udev-seat.c
  2. 2
      src/udev-seat.h

@ -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…
Cancel
Save