only add first backend to multi autocreate

This commit is contained in:
Tony Crisci 2017-12-21 18:38:58 -05:00
parent 9871cde604
commit 4cec7f54e2
1 changed files with 15 additions and 5 deletions

View File

@ -33,6 +33,10 @@ bool wlr_backend_start(struct wlr_backend *backend) {
}
void wlr_backend_destroy(struct wlr_backend *backend) {
if (!backend) {
return;
}
wl_signal_emit(&backend->events.destroy, backend);
if (backend->impl && backend->impl->destroy) {
backend->impl->destroy(backend);
@ -82,6 +86,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
struct wlr_backend *wl_backend = attempt_wl_backend(display);
if (wl_backend) {
wlr_multi_backend_add(backend, wl_backend);
return backend;
}
}
@ -90,18 +95,25 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
struct wlr_backend *x11_backend =
wlr_x11_backend_create(display, x11_display);
wlr_multi_backend_add(backend, x11_backend);
return backend;
}
// Attempt DRM+libinput
struct wlr_session *session = wlr_session_create(display);
if (!session) {
wlr_log(L_ERROR, "Failed to start a DRM session");
goto out;
wlr_backend_destroy(backend);
return NULL;
}
struct wlr_backend *libinput = wlr_libinput_backend_create(display, session);
if (libinput) {
wlr_multi_backend_add(backend, libinput);
} else {
wlr_log(L_ERROR, "Failed to start libinput backend");
wlr_backend_destroy(backend);
wlr_session_destroy(session);
return NULL;
}
int gpus[8];
@ -126,10 +138,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
if (!primary_drm) {
wlr_log(L_ERROR, "Failed to open any DRM device");
}
out:
if (wlr_multi_is_empty(backend)) {
wlr_backend_destroy(libinput);
wlr_session_destroy(session);
wlr_backend_destroy(backend);
return NULL;
}