|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
#include <wlr/backend/wayland.h>
|
|
|
|
|
#include <wlr/config.h>
|
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
#include "backend/multi.h"
|
|
|
|
|
|
|
|
|
|
/* WLR_HAS_X11_BACKEND needs to be after wlr/config.h */
|
|
|
|
|
#ifdef WLR_HAS_X11_BACKEND
|
|
|
|
@ -56,6 +57,13 @@ struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend) {
|
|
|
|
|
if (backend->impl->get_session) {
|
|
|
|
|
return backend->impl->get_session(backend);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t parse_outputs_env(const char *name) {
|
|
|
|
|
const char *outputs_str = getenv(name);
|
|
|
|
|
if (outputs_str == NULL) {
|
|
|
|
@ -158,11 +166,13 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
|
|
|
|
|
return attempt_headless_backend(display, create_renderer_func);
|
|
|
|
|
} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) {
|
|
|
|
|
// DRM and libinput need a session
|
|
|
|
|
if (!*session) {
|
|
|
|
|
*session = wlr_session_create(display);
|
|
|
|
|
if (!*session) {
|
|
|
|
|
wlr_log(WLR_ERROR, "failed to start a session");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(name, "libinput") == 0) {
|
|
|
|
|
return wlr_libinput_backend_create(display, *session);
|
|
|
|
@ -178,13 +188,12 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
|
|
|
|
|
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
|
|
|
|
wlr_renderer_create_func_t create_renderer_func) {
|
|
|
|
|
struct wlr_backend *backend = wlr_multi_backend_create(display);
|
|
|
|
|
struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
|
|
|
|
|
if (!backend) {
|
|
|
|
|
wlr_log(WLR_ERROR, "could not allocate multibackend");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_session *session = NULL;
|
|
|
|
|
|
|
|
|
|
char *names = getenv("WLR_BACKENDS");
|
|
|
|
|
if (names) {
|
|
|
|
|
names = strdup(names);
|
|
|
|
@ -197,12 +206,12 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
|
|
|
|
char *saveptr;
|
|
|
|
|
char *name = strtok_r(names, ",", &saveptr);
|
|
|
|
|
while (name != NULL) {
|
|
|
|
|
struct wlr_backend *subbackend =
|
|
|
|
|
attempt_backend_by_name(display, backend, &session, name, create_renderer_func);
|
|
|
|
|
struct wlr_backend *subbackend = attempt_backend_by_name(display,
|
|
|
|
|
backend, &multi->session, name, create_renderer_func);
|
|
|
|
|
if (subbackend == NULL) {
|
|
|
|
|
wlr_log(WLR_ERROR, "failed to start backend '%s'", name);
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
wlr_session_destroy(session);
|
|
|
|
|
wlr_session_destroy(multi->session);
|
|
|
|
|
free(names);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -210,7 +219,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
|
|
|
|
if (!wlr_multi_backend_add(backend, subbackend)) {
|
|
|
|
|
wlr_log(WLR_ERROR, "failed to add backend '%s'", name);
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
wlr_session_destroy(session);
|
|
|
|
|
wlr_session_destroy(multi->session);
|
|
|
|
|
free(names);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -245,29 +254,30 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Attempt DRM+libinput
|
|
|
|
|
session = wlr_session_create(display);
|
|
|
|
|
if (!session) {
|
|
|
|
|
multi->session = wlr_session_create(display);
|
|
|
|
|
if (!multi->session) {
|
|
|
|
|
wlr_log(WLR_ERROR, "Failed to start a DRM session");
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wlr_backend *libinput = wlr_libinput_backend_create(display, session);
|
|
|
|
|
struct wlr_backend *libinput = wlr_libinput_backend_create(display,
|
|
|
|
|
multi->session);
|
|
|
|
|
if (!libinput) {
|
|
|
|
|
wlr_log(WLR_ERROR, "Failed to start libinput backend");
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
wlr_session_destroy(session);
|
|
|
|
|
wlr_session_destroy(multi->session);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
wlr_multi_backend_add(backend, libinput);
|
|
|
|
|
|
|
|
|
|
struct wlr_backend *primary_drm =
|
|
|
|
|
attempt_drm_backend(display, backend, session, create_renderer_func);
|
|
|
|
|
struct wlr_backend *primary_drm = attempt_drm_backend(display, backend,
|
|
|
|
|
multi->session, create_renderer_func);
|
|
|
|
|
if (!primary_drm) {
|
|
|
|
|
wlr_log(WLR_ERROR, "Failed to open any DRM device");
|
|
|
|
|
wlr_backend_destroy(libinput);
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
wlr_session_destroy(session);
|
|
|
|
|
wlr_session_destroy(multi->session);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|