diff --git a/src/api/wayfire/nonstd/wlroots.hpp b/src/api/wayfire/nonstd/wlroots.hpp index 03a8f5a65..1901ff891 100644 --- a/src/api/wayfire/nonstd/wlroots.hpp +++ b/src/api/wayfire/nonstd/wlroots.hpp @@ -62,6 +62,7 @@ extern "C" #include #include #include +#include static constexpr uint32_t WLR_KEY_PRESSED = WL_KEYBOARD_KEY_STATE_PRESSED; static constexpr uint32_t WLR_KEY_RELEASED = WL_KEYBOARD_KEY_STATE_RELEASED; diff --git a/src/main.cpp b/src/main.cpp index 6a8d60401..7a1dc7f03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,7 @@ #include "wayfire/config-backend.hpp" #include "core/plugin-loader.hpp" #include "core/core-impl.hpp" +#include static void print_version() { @@ -388,27 +389,40 @@ int main(int argc, char *argv[]) core.ev_loop = wl_display_get_event_loop(core.display); core.backend = wlr_backend_autocreate(core.ev_loop, &core.session); - int drm_fd = wlr_backend_get_drm_fd(core.backend); - if (drm_fd < 0) + int drm_fd = -1; + char *drm_device = getenv("WLR_RENDER_DRM_DEVICE"); + if (drm_device) { - char *drm_device = getenv("WLR_RENDER_DRM_DEVICE"); - if (drm_device) - { - drm_fd = open(drm_device, O_RDWR | O_CLOEXEC); - } + drm_fd = open(drm_device, O_RDWR | O_CLOEXEC); + } else + { + drm_fd = wlr_backend_get_drm_fd(core.backend); + } - if (drm_fd < 0) - { - LOGE("Failed to get DRM file descriptor,", - " try specifying a valid WLR_RENDER_DRM_DEVICE!"); - wl_display_destroy_clients(core.display); - wl_display_destroy(core.display); - return EXIT_FAILURE; - } + if (drm_fd < 0) + { +#if WLR_HAS_UDMABUF_ALLOCATOR == 1 + LOGW("Failed to open DRM render device, consider specifying WLR_RENDER_DRM_DEVICE." + "Trying SW rendering instead."); +#else + LOGE("Failed to open DRM render device, consider specifying WLR_RENDER_DRM_DEVICE." + "If you want to use software rendering, ensure that wlroots has been compiled with udmabuf " + "allocator support (available in wlroots >= 0.19.0) and recompile Wayfire."); + wl_display_destroy_clients(core.display); + wl_display_destroy(core.display); + return EXIT_FAILURE; +#endif } core.renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd); - assert(core.renderer); + if (!core.renderer) + { + LOGE("Failed to create renderer"); + wl_display_destroy_clients(core.display); + wl_display_destroy(core.display); + return EXIT_FAILURE; + } + core.allocator = wlr_allocator_autocreate(core.backend, core.renderer); assert(core.allocator); core.egl = wlr_gles2_renderer_get_egl(core.renderer);