diff --git a/src/evdev.c b/src/evdev.c index 3b21afc6..d38f63bd 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -658,6 +658,7 @@ evdev_device_destroy(struct evdev_device *device) close(device->fd); free(device->devname); free(device->devnode); + free(device->output_name); free(device); } diff --git a/src/evdev.h b/src/evdev.h index 25b36315..36a52e34 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -55,6 +55,7 @@ struct evdev_device { struct evdev_dispatch *dispatch; char *devnode; char *devname; + char *output_name; int fd; struct { int min_x, max_x, min_y, max_y; diff --git a/src/udev-seat.c b/src/udev-seat.c index deceb50c..f9723f2f 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -123,8 +123,9 @@ device_added(struct udev_device *udev_device, struct udev_input *input) output_name = udev_device_get_property_value(udev_device, "WL_OUTPUT"); if (output_name) { + device->output_name = strdup(output_name); wl_list_for_each(output, &c->output_list, link) - if (strcmp(output->name, output_name) == 0) + if (strcmp(output->name, device->output_name) == 0) device->output = output; } @@ -343,6 +344,20 @@ drm_led_update(struct weston_seat *seat_base, enum weston_led leds) evdev_led_update(device, leds); } +static void +notify_output_create(struct wl_listener *listener, void *data) +{ + struct udev_seat *seat = container_of(listener, struct udev_seat, + output_create_listener); + struct evdev_device *device; + struct weston_output *output = data; + + wl_list_for_each(device, &seat->devices_list, link) + if (device->output_name && + strcmp(output->name, device->output_name) == 0) + device->output = output; +} + static struct udev_seat * udev_seat_create(struct weston_compositor *c, const char *seat_name) { @@ -355,6 +370,10 @@ udev_seat_create(struct weston_compositor *c, const char *seat_name) weston_seat_init(&seat->base, c, seat_name); seat->base.led_update = drm_led_update; + seat->output_create_listener.notify = notify_output_create; + wl_signal_add(&c->output_created_signal, + &seat->output_create_listener); + wl_list_init(&seat->devices_list); return seat; } @@ -363,6 +382,7 @@ static void udev_seat_destroy(struct udev_seat *seat) { weston_seat_release(&seat->base); + wl_list_remove(&seat->output_create_listener.link); free(seat); } diff --git a/src/udev-seat.h b/src/udev-seat.h index 4cb6f071..e0d491ab 100644 --- a/src/udev-seat.h +++ b/src/udev-seat.h @@ -32,6 +32,7 @@ struct udev_seat { struct weston_seat base; struct wl_list devices_list; + struct wl_listener output_create_listener; }; struct udev_input { @@ -42,7 +43,6 @@ struct udev_input { int enabled; }; - int udev_input_enable(struct udev_input *input, struct udev *udev); void udev_input_disable(struct udev_input *input); int udev_input_init(struct udev_input *input,