diff options
author | emersion <contact@emersion.fr> | 2018-05-15 00:07:41 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-19 09:08:59 +0100 |
commit | a1631dd9ee148ac2adfe664be44b0e463e29950a (patch) | |
tree | cc1108b65f2ca8e72cebf9ef7052fcd218040a43 | |
parent | 98088e78df054553ec846043ee913d0dcf39de16 (diff) |
backend: add WLR_BACKEND env variable
-rw-r--r-- | backend/backend.c | 42 | ||||
-rw-r--r-- | docs/env_vars.md | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/backend/backend.c b/backend/backend.c index 20bf42b3..0ea42cf5 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -6,6 +6,7 @@ #include <unistd.h> #include <wayland-server.h> #include <wlr/backend/drm.h> +#include <wlr/backend/headless.h> #include <wlr/backend/interface.h> #include <wlr/backend/libinput.h> #include <wlr/backend/multi.h> @@ -101,6 +102,35 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display, } #endif +static struct wlr_backend *attempt_headless_backend( + struct wl_display *display) { + struct wlr_backend *backend = wlr_headless_backend_create(display); + if (backend == NULL) { + return NULL; + } + + size_t outputs = parse_outputs_env("WLR_HEADLESS_OUTPUTS"); + for (size_t i = 0; i < outputs; ++i) { + wlr_headless_add_output(backend, 1280, 720); + } + + return backend; +} + +static struct wlr_backend *attempt_backend_by_name(struct wl_display *display, + const char *name) { + if (strcmp(name, "wayland") == 0) { + return attempt_wl_backend(display); +#ifdef WLR_HAS_X11_BACKEND + } else if (strcmp(name, "x11") == 0) { + return attempt_x11_backend(display, NULL); +#endif + } else if (strcmp(name, "headless") == 0) { + return attempt_headless_backend(display); + } + return NULL; +} + struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { struct wlr_backend *backend = wlr_multi_backend_create(display); if (!backend) { @@ -108,6 +138,18 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { return NULL; } + const char *name = getenv("WLR_BACKEND"); + if (name) { + struct wlr_backend *subbackend = attempt_backend_by_name(display, name); + if (subbackend) { + wlr_multi_backend_add(backend, subbackend); + return backend; + } else { + wlr_log(L_ERROR, "unrecognized backend '%s'", name); + return NULL; + } + } + if (getenv("WAYLAND_DISPLAY") || getenv("_WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET")) { struct wlr_backend *wl_backend = attempt_wl_backend(display); diff --git a/docs/env_vars.md b/docs/env_vars.md index 5744701a..db85d4c5 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -5,6 +5,7 @@ wlroots specific * *WLR_DRM_DEVICES*: specifies the DRM devices (as a colon separated list) instead of auto probing them. The first existing device in this list is considered the primary DRM device. * *WLR_DRM_NO_ATOMIC*: set to 1 to use legacy DRM interface instead of atomic mode setting * *WLR_LIBINPUT_NO_DEVICES*: set to 1 to not fail without any input devices +* *WLR_BACKEND*: force a specific backend to be used (one of: wayland, x11, headless) * *WLR_WL_OUTPUTS*: when using the wayland backend specifies the number of outputs * *WLR_X11_OUTPUTS*: when using the X11 backend specifies the number of outputs |