diff options
Diffstat (limited to 'src/udev-seat.c')
-rw-r--r-- | src/udev-seat.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/udev-seat.c b/src/udev-seat.c index ffaf08aa..f9723f2f 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -83,11 +83,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input) device = evdev_device_create(&seat->base, devnode, fd); if (device == EVDEV_UNHANDLED_DEVICE) { - close(fd); + weston_launcher_close(c->launcher, fd); weston_log("not using input device '%s'.\n", devnode); return 0; } else if (device == NULL) { - close(fd); + weston_launcher_close(c->launcher, fd); weston_log("failed to create input device '%s'.\n", devnode); return 0; } @@ -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; } @@ -219,9 +220,11 @@ evdev_udev_handler(int fd, uint32_t mask, void *data) if (!strcmp(device->devnode, devnode)) { weston_log("input device %s, %s removed\n", device->devname, device->devnode); + weston_launcher_close(input->compositor->launcher, + device->fd); evdev_device_destroy(device); - break; - } + break; + } } } @@ -278,8 +281,11 @@ udev_input_remove_devices(struct udev_input *input) struct udev_seat *seat; wl_list_for_each(seat, &input->compositor->seat_list, base.link) { - wl_list_for_each_safe(device, next, &seat->devices_list, link) + wl_list_for_each_safe(device, next, &seat->devices_list, link) { + weston_launcher_close(input->compositor->launcher, + device->fd); evdev_device_destroy(device); + } if (seat->base.keyboard) notify_keyboard_focus_out(&seat->base); @@ -338,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) { @@ -350,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; } @@ -358,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); } |