diff --git a/src/compositor-drm.c b/src/compositor-drm.c index cbfa786f..f8f1262c 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2435,7 +2435,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 d1013e8b..f8d2fe05 100644 --- a/src/compositor-fbdev.c +++ b/src/compositor-fbdev.c @@ -824,7 +824,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 e7c0e0dd..78221a05 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 51eefcd8..7e4330a3 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 dda8a16d..e388f13e 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,