backend: error out in autocreate without libinput support

The libinput backend is now optional. However, this means that a
user building wlroots without the correct libinput dependencies
will end up with a compositor which doesn't respond to input events.

wlr_backend_autocreate is supposed to return a sensible setup, so in
this case let's just error out and explain what happened. Users can
suppress the check by setting WLR_LIBINPUT_NO_DEVICES=1 (already used
to suppress the zero input device case inside the libinput backend).

Compositors which really want to create a bare DRM backend can easily
create it manually instead of using wlr_backend_autocreate.
This commit is contained in:
Simon Ser 2021-12-19 16:39:57 +01:00 committed by Simon Zeni
parent b5a019d575
commit ec28457508

View file

@ -364,6 +364,19 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
return NULL; return NULL;
} }
wlr_multi_backend_add(backend, libinput); wlr_multi_backend_add(backend, libinput);
#else
const char *no_devs = getenv("WLR_LIBINPUT_NO_DEVICES");
if (no_devs && strcmp(no_devs, "1") == 0) {
wlr_log(WLR_INFO, "WLR_LIBINPUT_NO_DEVICES is set, "
"starting without libinput backend");
} else {
wlr_log(WLR_ERROR, "libinput support is not compiled in, "
"refusing to start");
wlr_log(WLR_ERROR, "Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check");
wlr_session_destroy(multi->session);
wlr_backend_destroy(backend);
return NULL;
}
#endif #endif
#if WLR_HAS_DRM_BACKEND #if WLR_HAS_DRM_BACKEND