From 7d0290bae7be060e8cf51acd34d9e1f0efbbc339 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Fri, 13 Jun 2025 17:05:13 -0400 Subject: [PATCH] sway/config: add allow_drm_leasing config --- include/sway/config.h | 1 + include/sway/output.h | 1 + sway/config/output.c | 12 ++++++++++-- sway/ipc-json.c | 2 ++ sway/sway-output.5.scd | 5 +++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 3c380933e..544fdfd5f 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -291,6 +291,7 @@ struct output_config { bool set_color_transform; struct wlr_color_transform *color_transform; int allow_tearing; + int allow_drm_leasing; int hdr; char *background; diff --git a/include/sway/output.h b/include/sway/output.h index 787527ee7..4d82f9eca 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -70,6 +70,7 @@ struct sway_output { struct wl_event_source *repaint_timer; bool allow_tearing; + bool allow_drm_leasing; bool hdr; }; diff --git a/sway/config/output.c b/sway/config/output.c index ed8147b8b..5b91124d3 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -79,6 +79,7 @@ struct output_config *new_output_config(const char *name) { oc->color_transform = NULL; oc->power = -1; oc->allow_tearing = -1; + oc->allow_drm_leasing = -1; oc->hdr = -1; return oc; } @@ -155,6 +156,9 @@ static void supersede_output_config(struct output_config *dst, struct output_con if (src->allow_tearing != -1) { dst->allow_tearing = -1; } + if (src->allow_drm_leasing != -1) { + dst->allow_drm_leasing = -1; + } if (src->hdr != -1) { dst->hdr = -1; } @@ -233,6 +237,9 @@ static void merge_output_config(struct output_config *dst, struct output_config if (src->allow_tearing != -1) { dst->allow_tearing = src->allow_tearing; } + if (src->allow_drm_leasing != -1) { + dst->allow_drm_leasing = src->allow_drm_leasing; + } if (src->hdr != -1) { dst->hdr = src->hdr; } @@ -278,11 +285,11 @@ void store_output_config(struct output_config *oc) { sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " "position %d,%d scale %f subpixel %s transform %d) (bg %s %s) (power %d) " - "(max render time: %d) (allow tearing: %d) (hdr: %d)", + "(max render time: %d) (allow tearing: %d) (allow drm leasing: %d) (hdr: %d)", oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, oc->x, oc->y, oc->scale, sway_wl_output_subpixel_to_string(oc->subpixel), oc->transform, oc->background, oc->background_option, oc->power, - oc->max_render_time, oc->allow_tearing, oc->hdr); + oc->max_render_time, oc->allow_tearing, oc->allow_drm_leasing, oc->hdr); // If the configuration was not merged into an existing configuration, add // it to the list. Otherwise we're done with it and can free it. @@ -622,6 +629,7 @@ static bool finalize_output_config(struct output_config *oc, struct sway_output output->max_render_time = oc && oc->max_render_time > 0 ? oc->max_render_time : 0; output->allow_tearing = oc && oc->allow_tearing > 0; + output->allow_drm_leasing = oc && oc->allow_drm_leasing > 0; output->hdr = applied->image_description != NULL; return true; diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 3b69ad384..ca960a59e 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -409,6 +409,8 @@ static void ipc_json_describe_enabled_output(struct sway_output *output, json_object_object_add(object, "max_render_time", json_object_new_int(output->max_render_time)); json_object_object_add(object, "allow_tearing", json_object_new_boolean(output->allow_tearing)); + json_object_object_add(object, "allow_drm_leasing", + json_object_new_boolean(output->allow_drm_leasing)); json_object_object_add(object, "hdr", json_object_new_boolean(output->hdr)); } diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index cc48589c3..000256b0e 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -210,6 +210,11 @@ must be separated by one space. For example: This setting only has effect when a window is fullscreen on the output. +*output* allow_drm_leasing yes|no + Allows or disallows leasing a DRM output. The DRM lease interface must be + active when calling this command. Outputs offered for leasing will be + disabled when leased by a client. + *output* hdr on|off|toggle Enables or disables HDR (High Dynamic Range). HDR enables a larger color gamut and brightness range. HDR uses the BT2020 primaries and the PQ