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