From 7f6984d317147a2ad70783503bfafb1850b9621d Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sat, 12 Jul 2025 18:45:47 +0200 Subject: [PATCH] Make wlroots DRM backend optional --- include/labwc.h | 1 - src/config/session.c | 10 +++++++++- src/output.c | 11 ++++++++--- src/server.c | 14 +++++++++++--- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/labwc.h b/include/labwc.h index cff78588..c28cd6f6 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/src/config/session.c b/src/config/session.c index 5408bbcb..ab472f19 100644 --- a/src/config/session.c +++ b/src/config/session.c @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include #include "common/buf.h" #include "common/dir.h" @@ -21,6 +21,10 @@ #include "config/session.h" #include "labwc.h" +#if WLR_HAS_DRM_BACKEND + #include +#endif + static const char *const env_vars[] = { "DISPLAY", "WAYLAND_DISPLAY", @@ -177,6 +181,7 @@ env_dir_cleanup: return success; } +#if WLR_HAS_DRM_BACKEND static void backend_check_drm(struct wlr_backend *backend, void *is_drm) { @@ -184,6 +189,7 @@ backend_check_drm(struct wlr_backend *backend, void *is_drm) *(bool *)is_drm = true; } } +#endif static bool should_update_activation(struct server *server) @@ -207,7 +213,9 @@ should_update_activation(struct server *server) /* With no valid preference, update when a DRM backend is in use */ bool have_drm = false; +#if WLR_HAS_DRM_BACKEND wlr_multi_for_each_backend(server->backend, backend_check_drm, &have_drm); +#endif return have_drm; } diff --git a/src/output.c b/src/output.c index 3b4a26ca..5359d7ca 100644 --- a/src/output.c +++ b/src/output.c @@ -9,10 +9,10 @@ #define _POSIX_C_SOURCE 200809L #include #include -#include +#include #include +#include #include -#include #include #include #include @@ -33,6 +33,11 @@ #include "view.h" #include "xwayland.h" +#if WLR_HAS_DRM_BACKEND + #include + #include +#endif + bool output_get_tearing_allowance(struct output *output) { @@ -453,7 +458,7 @@ handle_new_output(struct wl_listener *listener, void *data) * * TODO: remove once labwc starts tracking 0.20.x and the fix has been merged. */ -#if LAB_WLR_VERSION_AT_LEAST(0, 19, 1) +#if WLR_HAS_DRM_BACKEND && LAB_WLR_VERSION_AT_LEAST(0, 19, 1) if (server->drm_lease_manager && wlr_output_is_drm(wlr_output)) { wlr_drm_lease_v1_manager_offer_output( server->drm_lease_manager, wlr_output); diff --git a/src/server.c b/src/server.c index 214885b1..36c7af00 100644 --- a/src/server.c +++ b/src/server.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -30,11 +31,14 @@ #include #if HAVE_XWAYLAND -#include -#include "xwayland-shell-v1-protocol.h" + #include + #include "xwayland-shell-v1-protocol.h" +#endif + +#if WLR_HAS_DRM_BACKEND + #include #endif -#include "drm-lease-v1-protocol.h" #include "common/macros.h" #include "common/scaled-scene-buffer.h" #include "config/rcxml.h" @@ -173,6 +177,7 @@ handle_sigchld(int signal, void *data) return 0; } +#if WLR_HAS_DRM_BACKEND static void handle_drm_lease_request(struct wl_listener *listener, void *data) { @@ -184,6 +189,7 @@ handle_drm_lease_request(struct wl_listener *listener, void *data) return; } } +#endif static bool protocol_is_privileged(const struct wl_interface *iface) @@ -666,6 +672,7 @@ server_init(struct server *server) session_lock_init(server); +#if WLR_HAS_DRM_BACKEND server->drm_lease_manager = wlr_drm_lease_v1_manager_create( server->wl_display, server->backend); if (server->drm_lease_manager) { @@ -676,6 +683,7 @@ server_init(struct server *server) wlr_log(WLR_DEBUG, "Failed to create wlr_drm_lease_device_v1"); wlr_log(WLR_INFO, "VR will not be available"); } +#endif server->output_power_manager_v1 = wlr_output_power_manager_v1_create(server->wl_display);