[PATCH 3/6] compositor-drm: destroy evdev driver properly when finishing compositor

Tiago Vignatti vignatti at freedesktop.org
Mon Dec 19 02:30:25 PST 2011


From: Tiago Vignatti <tiago.vignatti at intel.com>

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 compositor/compositor-drm.c |    4 ++++
 compositor/compositor.h     |    3 +++
 compositor/evdev.c          |   27 +++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c
index 4744a46..9c8e506 100644
--- a/compositor/compositor-drm.c
+++ b/compositor/compositor-drm.c
@@ -772,11 +772,15 @@ static void
 drm_destroy(struct wlsc_compositor *ec)
 {
 	struct drm_compositor *d = (struct drm_compositor *) ec;
+	struct wlsc_input_device *input, *next;
 
 	wlsc_compositor_shutdown(ec);
 	gbm_device_destroy(d->gbm);
 	tty_destroy(d->tty);
 
+	wl_list_for_each_safe(input, next, &ec->input_device_list, link)
+		evdev_input_destroy(input);
+
 	free(d);
 }
 
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 0b3f82e..0c29de5 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -377,6 +377,9 @@ void
 evdev_input_add_devices(struct wlsc_compositor *c,
 			struct udev *udev, const char *seat);
 
+void
+evdev_input_destroy(struct wlsc_input_device *input_base);
+
 enum {
 	TTY_ENTER_VT,
 	TTY_LEAVE_VT
diff --git a/compositor/evdev.c b/compositor/evdev.c
index 43776c8..2578450 100644
--- a/compositor/evdev.c
+++ b/compositor/evdev.c
@@ -537,3 +537,30 @@ evdev_input_add_devices(struct wlsc_compositor *c,
 
 	c->input_device = &input->base.input_device;
 }
+
+static void
+evdev_remove_devices(struct wlsc_input_device *input_base)
+{
+	struct evdev_input *input = (struct evdev_input *) input_base;
+	struct evdev_input_device *device, *next;
+
+        wl_list_for_each_safe(device, next, &input->devices_list, link) {
+		fprintf(stderr, "evdev input device: removed: %s\n", device->devnode);
+		wl_event_source_remove(device->source);
+		wl_list_remove(&device->link);
+		close(device->fd);
+		free(device->devnode);
+		free(device);
+	}
+}
+
+void
+evdev_input_destroy(struct wlsc_input_device *input_base)
+{
+	struct evdev_input *input = (struct evdev_input *) input_base;
+
+	evdev_remove_devices(input_base);
+	wl_list_remove(&input->base.link);
+	free(input->seat_id);
+	free(input);
+}
-- 
1.7.5.4



More information about the wayland-devel mailing list