diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-26 20:15:52 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-28 13:28:15 -0500 |
commit | e795ea6a0c5420fba505de074ad20797a9797d07 (patch) | |
tree | fdc137a8e01fbec768f71808fde815a1b6b3ef1e | |
parent | 5b64e2fc31ede4777343e06087d7b921b28be674 (diff) |
Make DRM backend optional
-rw-r--r-- | sway/config/output.c | 12 | ||||
-rw-r--r-- | sway/desktop/output.c | 10 | ||||
-rw-r--r-- | sway/server.c | 11 |
3 files changed, 28 insertions, 5 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 9c7082d0..914cf6c4 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -6,10 +6,10 @@ #include <sys/socket.h> #include <sys/wait.h> #include <unistd.h> +#include <wlr/config.h> #include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output.h> -#include <wlr/backend/drm.h> #include "sway/config.h" #include "sway/input/cursor.h" #include "sway/output.h" @@ -17,6 +17,10 @@ #include "log.h" #include "util.h" +#if WLR_HAS_DRM_BACKEND +#include <wlr/backend/drm.h> +#endif + int output_name_cmp(const void *item, const void *data) { const struct output_config *output = item; const char *name = data; @@ -286,6 +290,7 @@ static void set_mode(struct wlr_output *output, struct wlr_output_state *pending static void set_modeline(struct wlr_output *output, struct wlr_output_state *pending, drmModeModeInfo *drm_mode) { +#if WLR_HAS_DRM_BACKEND if (!wlr_output_is_drm(output)) { sway_log(SWAY_ERROR, "Modeline can only be set to DRM output"); return; @@ -295,6 +300,9 @@ static void set_modeline(struct wlr_output *output, if (mode) { wlr_output_state_set_mode(pending, mode); } +#else + sway_log(SWAY_ERROR, "Modeline can only be set to DRM output"); +#endif } /* Some manufacturers hardcode the aspect-ratio of the output in the physical @@ -436,9 +444,11 @@ static void queue_output_config(struct output_config *oc, enum wl_output_transform tr = WL_OUTPUT_TRANSFORM_NORMAL; if (oc && oc->transform >= 0) { tr = oc->transform; +#if WLR_HAS_DRM_BACKEND } else if (wlr_output_is_drm(wlr_output)) { tr = wlr_drm_connector_get_panel_orientation(wlr_output); sway_log(SWAY_DEBUG, "Auto-detected output transform: %d", tr); +#endif } if (wlr_output->transform != tr) { sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, tr); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 04bddf86..6999a382 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -4,11 +4,10 @@ #include <strings.h> #include <time.h> #include <wayland-server-core.h> -#include <wlr/backend/drm.h> +#include <wlr/config.h> #include <wlr/backend/headless.h> #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_buffer.h> -#include <wlr/types/wlr_drm_lease_v1.h> #include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output.h> @@ -31,6 +30,11 @@ #include "sway/tree/view.h" #include "sway/tree/workspace.h" +#if WLR_HAS_DRM_BACKEND +#include <wlr/backend/drm.h> +#include <wlr/types/wlr_drm_lease_v1.h> +#endif + struct sway_output *output_by_name_or_id(const char *name_or_id) { for (int i = 0; i < root->outputs->length; ++i) { struct sway_output *output = root->outputs->items[i]; @@ -923,10 +927,12 @@ void handle_new_output(struct wl_listener *listener, void *data) { if (wlr_output->non_desktop) { sway_log(SWAY_DEBUG, "Not configuring non-desktop output"); struct sway_output_non_desktop *non_desktop = output_non_desktop_create(wlr_output); +#if WLR_HAS_DRM_BACKEND if (server->drm_lease_manager) { wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager, wlr_output); } +#endif list_add(root->non_desktop_outputs, non_desktop); return; } diff --git a/sway/server.c b/sway/server.c index b750d10c..9208a838 100644 --- a/sway/server.c +++ b/sway/server.c @@ -7,13 +7,11 @@ #include <wlr/backend.h> #include <wlr/backend/headless.h> #include <wlr/backend/multi.h> -#include <wlr/backend/session.h> #include <wlr/config.h> #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_content_type_v1.h> #include <wlr/types/wlr_data_control_v1.h> -#include <wlr/types/wlr_drm_lease_v1.h> #include <wlr/types/wlr_drm.h> #include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_gamma_control_v1.h> @@ -46,13 +44,19 @@ #include "sway/output.h" #include "sway/server.h" #include "sway/tree/root.h" + #if HAVE_XWAYLAND #include "sway/xwayland.h" #endif +#if WLR_HAS_DRM_BACKEND +#include <wlr/types/wlr_drm_lease_v1.h> +#endif + #define SWAY_XDG_SHELL_VERSION 2 #define SWAY_LAYER_SHELL_VERSION 3 +#if WLR_HAS_DRM_BACKEND static void handle_drm_lease_request(struct wl_listener *listener, void *data) { /* We only offer non-desktop outputs, but in the future we might want to do * more logic here. */ @@ -64,6 +68,7 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) { wlr_drm_lease_request_v1_reject(req); } } +#endif bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Initializing Wayland server"); @@ -189,6 +194,7 @@ bool server_init(struct sway_server *server) { sway_session_lock_init(); +#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) { @@ -199,6 +205,7 @@ bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Failed to create wlr_drm_lease_device_v1"); sway_log(SWAY_INFO, "VR will not be available"); } +#endif wlr_export_dmabuf_manager_v1_create(server->wl_display); wlr_screencopy_manager_v1_create(server->wl_display); |