[PATCH weston 2/3] udev-seat: Make udev_input own its own udev object reference

Jonas Ådahl jadahl at gmail.com
Wed Mar 12 14:08:41 PDT 2014


No functional changes; API simplification in preparation for multiple
input backends.

Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 src/compositor-drm.c   |  2 +-
 src/compositor-fbdev.c |  2 +-
 src/compositor-rpi.c   |  2 +-
 src/udev-seat.c        | 11 +++++++----
 src/udev-seat.h        |  3 ++-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 0d9ac33..e489957 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2399,7 +2399,7 @@ session_notify(struct wl_listener *listener, void *data)
 		compositor->state = ec->prev_state;
 		drm_compositor_set_modes(ec);
 		weston_compositor_damage_all(compositor);
-		udev_input_enable(&ec->input, ec->udev);
+		udev_input_enable(&ec->input);
 	} else {
 		weston_log("deactivating session\n");
 		udev_input_disable(&ec->input);
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 0d96269..ca38c42 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -822,7 +822,7 @@ session_notify(struct wl_listener *listener, void *data)
 
 		weston_compositor_damage_all(&compositor->base);
 
-		udev_input_enable(&compositor->input, compositor->udev);
+		udev_input_enable(&compositor->input);
 	} else {
 		weston_log("leaving VT\n");
 		udev_input_disable(&compositor->input);
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index e7c0e0d..78221a0 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -441,7 +441,7 @@ session_notify(struct wl_listener *listener, void *data)
 		weston_log("activating session\n");
 		compositor->base.state = compositor->prev_state;
 		weston_compositor_damage_all(&compositor->base);
-		udev_input_enable(&compositor->input, compositor->udev);
+		udev_input_enable(&compositor->input);
 	} else {
 		weston_log("deactivating session\n");
 		udev_input_disable(&compositor->input);
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 51eefcd..7e4330a 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -237,13 +237,13 @@ out:
 }
 
 int
-udev_input_enable(struct udev_input *input, struct udev *udev)
+udev_input_enable(struct udev_input *input)
 {
 	struct wl_event_loop *loop;
 	struct weston_compositor *c = input->compositor;
 	int fd;
 
-	input->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
+	input->udev_monitor = udev_monitor_new_from_netlink(input->udev, "udev");
 	if (!input->udev_monitor) {
 		weston_log("udev: failed to create the udev monitor\n");
 		return -1;
@@ -268,7 +268,7 @@ udev_input_enable(struct udev_input *input, struct udev *udev)
 		return -1;
 	}
 
-	if (udev_input_add_devices(input, udev) < 0)
+	if (udev_input_add_devices(input, input->udev) < 0)
 		return -1;
 
 	input->enabled = 1;
@@ -316,7 +316,9 @@ udev_input_init(struct udev_input *input, struct weston_compositor *c, struct ud
 	memset(input, 0, sizeof *input);
 	input->seat_id = strdup(seat_id);
 	input->compositor = c;
-	if (udev_input_enable(input, udev) < 0)
+	input->udev = udev;
+	input->udev = udev_ref(udev);
+	if (udev_input_enable(input) < 0)
 		goto err;
 
 	return 0;
@@ -333,6 +335,7 @@ udev_input_destroy(struct udev_input *input)
 	udev_input_disable(input);
 	wl_list_for_each_safe(seat, next, &input->compositor->seat_list, base.link)
 		udev_seat_destroy(seat);
+	udev_unref(input->udev);
 	free(input->seat_id);
 }
 
diff --git a/src/udev-seat.h b/src/udev-seat.h
index dda8a16..e388f13 100644
--- a/src/udev-seat.h
+++ b/src/udev-seat.h
@@ -36,6 +36,7 @@ struct udev_seat {
 };
 
 struct udev_input {
+	struct udev *udev;
 	struct udev_monitor *udev_monitor;
 	struct wl_event_source *udev_monitor_source;
 	char *seat_id;
@@ -43,7 +44,7 @@ struct udev_input {
 	int enabled;
 };
 
-int udev_input_enable(struct udev_input *input, struct udev *udev);
+int udev_input_enable(struct udev_input *input);
 void udev_input_disable(struct udev_input *input);
 int udev_input_init(struct udev_input *input,
 		    struct weston_compositor *c,
-- 
1.8.3.2



More information about the wayland-devel mailing list