backend/libinput: drop wl_display argument

We can grab the event loop from the wlr_session instead.
master
Simon Ser 1 year ago committed by Kirill Primak
parent 682dbf36e5
commit f5e8fa48f3

@ -291,10 +291,9 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
#endif #endif
} }
static struct wlr_backend *attempt_libinput_backend(struct wl_display *display, static struct wlr_backend *attempt_libinput_backend(struct wlr_session *session) {
struct wlr_session *session) {
#if WLR_HAS_LIBINPUT_BACKEND #if WLR_HAS_LIBINPUT_BACKEND
return wlr_libinput_backend_create(display, session); return wlr_libinput_backend_create(session);
#else #else
wlr_log(WLR_ERROR, "Cannot create libinput backend: disabled at compile-time"); wlr_log(WLR_ERROR, "Cannot create libinput backend: disabled at compile-time");
return NULL; return NULL;
@ -322,7 +321,7 @@ static bool attempt_backend_by_name(struct wl_display *display,
} }
if (strcmp(name, "libinput") == 0) { if (strcmp(name, "libinput") == 0) {
backend = attempt_libinput_backend(display, *session_ptr); backend = attempt_libinput_backend(*session_ptr);
} else { } else {
// attempt_drm_backend() adds the multi drm backends itself // attempt_drm_backend() adds the multi drm backends itself
return attempt_drm_backend(display, multi, *session_ptr) != NULL; return attempt_drm_backend(display, multi, *session_ptr) != NULL;
@ -415,7 +414,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
goto error; goto error;
} }
struct wlr_backend *libinput = attempt_libinput_backend(display, session); struct wlr_backend *libinput = attempt_libinput_backend(session);
if (libinput) { if (libinput) {
wlr_multi_backend_add(multi, libinput); wlr_multi_backend_add(multi, libinput);
if (!auto_backend_monitor_create(multi, libinput)) { if (!auto_backend_monitor_create(multi, libinput)) {

@ -115,12 +115,10 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
} }
} }
struct wl_event_loop *event_loop =
wl_display_get_event_loop(backend->display);
if (backend->input_event) { if (backend->input_event) {
wl_event_source_remove(backend->input_event); wl_event_source_remove(backend->input_event);
} }
backend->input_event = wl_event_loop_add_fd(event_loop, libinput_fd, backend->input_event = wl_event_loop_add_fd(backend->session->event_loop, libinput_fd,
WL_EVENT_READABLE, handle_libinput_readable, backend); WL_EVENT_READABLE, handle_libinput_readable, backend);
if (!backend->input_event) { if (!backend->input_event) {
wlr_log(WLR_ERROR, "Failed to create input event on event loop"); wlr_log(WLR_ERROR, "Failed to create input event on event loop");
@ -144,7 +142,6 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
wlr_backend_finish(wlr_backend); wlr_backend_finish(wlr_backend);
wl_list_remove(&backend->display_destroy.link);
wl_list_remove(&backend->session_destroy.link); wl_list_remove(&backend->session_destroy.link);
wl_list_remove(&backend->session_signal.link); wl_list_remove(&backend->session_signal.link);
@ -186,14 +183,7 @@ static void handle_session_destroy(struct wl_listener *listener, void *data) {
backend_destroy(&backend->backend); backend_destroy(&backend->backend);
} }
static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_backend *wlr_libinput_backend_create(struct wlr_session *session) {
struct wlr_libinput_backend *backend =
wl_container_of(listener, backend, display_destroy);
backend_destroy(&backend->backend);
}
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
struct wlr_session *session) {
struct wlr_libinput_backend *backend = calloc(1, sizeof(*backend)); struct wlr_libinput_backend *backend = calloc(1, sizeof(*backend));
if (!backend) { if (!backend) {
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno)); wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
@ -204,7 +194,6 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
wl_list_init(&backend->devices); wl_list_init(&backend->devices);
backend->session = session; backend->session = session;
backend->display = display;
backend->session_signal.notify = session_signal; backend->session_signal.notify = session_signal;
wl_signal_add(&session->events.active, &backend->session_signal); wl_signal_add(&session->events.active, &backend->session_signal);
@ -212,9 +201,6 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
backend->session_destroy.notify = handle_session_destroy; backend->session_destroy.notify = handle_session_destroy;
wl_signal_add(&session->events.destroy, &backend->session_destroy); wl_signal_add(&session->events.destroy, &backend->session_destroy);
backend->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &backend->display_destroy);
return &backend->backend; return &backend->backend;
} }

@ -18,12 +18,10 @@ struct wlr_libinput_backend {
struct wlr_backend backend; struct wlr_backend backend;
struct wlr_session *session; struct wlr_session *session;
struct wl_display *display;
struct libinput *libinput_context; struct libinput *libinput_context;
struct wl_event_source *input_event; struct wl_event_source *input_event;
struct wl_listener display_destroy;
struct wl_listener session_destroy; struct wl_listener session_destroy;
struct wl_listener session_signal; struct wl_listener session_signal;

@ -16,8 +16,7 @@
struct wlr_input_device; struct wlr_input_device;
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, struct wlr_backend *wlr_libinput_backend_create(struct wlr_session *session);
struct wlr_session *session);
/** /**
* Gets the underlying struct libinput_device handle for the given input device. * Gets the underlying struct libinput_device handle for the given input device.
*/ */

Loading…
Cancel
Save