uint32_t prev_state;
clockid_t clock;
+ struct udev_input input;
};
struct drm_mode {
drm_destroy(struct weston_compositor *ec)
{
struct drm_compositor *d = (struct drm_compositor *) ec;
- struct udev_input *input, *next;
- wl_list_for_each_safe(input, next, &ec->seat_list, base.link)
- udev_input_destroy(input);
+ udev_input_destroy(&d->input);
wl_event_source_remove(d->udev_drm_source);
wl_event_source_remove(d->drm_source);
vt_func(struct weston_compositor *compositor, int event)
{
struct drm_compositor *ec = (struct drm_compositor *) compositor;
- struct udev_input *input;
struct drm_sprite *sprite;
struct drm_output *output;
compositor->state = ec->prev_state;
drm_compositor_set_modes(ec);
weston_compositor_damage_all(compositor);
- wl_list_for_each(input, &compositor->seat_list, base.link)
- udev_input_enable(input, ec->udev);
+ udev_input_enable(&ec->input, ec->udev);
break;
case TTY_LEAVE_VT:
weston_log("leaving VT\n");
- wl_list_for_each(input, &compositor->seat_list, base.link)
- udev_input_disable(input);
+ udev_input_disable(&ec->input);
compositor->focus = 0;
ec->prev_state = compositor->state;
struct drm_compositor *ec;
struct udev_device *drm_device;
struct wl_event_loop *loop;
- struct udev_input *udev_input, *next;
const char *path;
uint32_t key;
path = NULL;
- if (udev_input_create(&ec->base, ec->udev, seat_id) == NULL) {
+ if (udev_input_init(&ec->input, &ec->base, ec->udev, seat_id) < 0) {
weston_log("failed to create input devices\n");
goto err_sprite;
}
udev_monitor_unref(ec->udev_monitor);
err_drm_source:
wl_event_source_remove(ec->drm_source);
- wl_list_for_each_safe(udev_input, next, &ec->base.seat_list, base.link)
- udev_input_destroy(udev_input);
+ udev_input_destroy(&ec->input);
err_sprite:
ec->base.renderer->destroy(&ec->base);
gbm_device_destroy(ec->gbm);
struct udev *udev;
struct tty *tty;
+ struct udev_input input;
};
struct fbdev_screeninfo {
fbdev_compositor_destroy(struct weston_compositor *base)
{
struct fbdev_compositor *compositor = to_fbdev_compositor(base);
- struct udev_input *input, *next;
- /* Destroy all inputs. */
- wl_list_for_each_safe(input, next, &compositor->base.seat_list, base.link)
- udev_input_destroy(input);
+ udev_input_destroy(&compositor->input);
/* Destroy the output. */
weston_compositor_shutdown(&compositor->base);
vt_func(struct weston_compositor *base, int event)
{
struct fbdev_compositor *compositor = to_fbdev_compositor(base);
- struct udev_input *input;
struct weston_output *output;
switch (event) {
weston_compositor_damage_all(&compositor->base);
- wl_list_for_each(input, &compositor->base.seat_list, base.link)
- udev_input_enable(input, compositor->udev);
+ udev_input_enable(&compositor->input, compositor->udev);
break;
case TTY_LEAVE_VT:
weston_log("leaving VT\n");
- wl_list_for_each(input, &compositor->base.seat_list, base.link)
- udev_input_disable(input);
+ udev_input_disable(&compositor->input);
wl_list_for_each(output, &compositor->base.output_list, link) {
fbdev_output_disable(output);
if (fbdev_output_create(compositor, param->device) < 0)
goto out_pixman;
- udev_input_create(&compositor->base, compositor->udev, seat);
+ udev_input_init(&compositor->input, &compositor->base, compositor->udev, seat);
return &compositor->base;
evdev_led_update(device, leds);
}
-struct udev_input *
-udev_input_create(struct weston_compositor *c, struct udev *udev,
+int
+udev_input_init(struct udev_input *input, struct weston_compositor *c, struct udev *udev,
const char *seat_id)
{
- struct udev_input *input;
-
- input = malloc(sizeof *input);
- if (input == NULL)
- return NULL;
-
memset(input, 0, sizeof *input);
weston_seat_init(&input->base, c, "default");
input->base.led_update = drm_led_update;
if (udev_input_enable(input, udev) < 0)
goto err;
- return input;
+ return 0;
err:
free(input->seat_id);
- free(input);
- return NULL;
+ return -1;
}
void
weston_seat_release(&input->base);
free(input->seat_id);
- free(input);
}
int udev_input_enable(struct udev_input *input, struct udev *udev);
void udev_input_disable(struct udev_input *input);
-struct udev_input *udev_input_create(struct weston_compositor *c,
- struct udev *udev,
- const char *seat_id);
+int udev_input_init(struct udev_input *input,
+ struct weston_compositor *c,
+ struct udev *udev,
+ const char *seat_id);
void udev_input_destroy(struct udev_input *input);
#endif