From cc342107690631cf1ff003fed0b1cdb072491c63 Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Sat, 8 Jun 2024 11:28:42 +0200
Subject: [PATCH] Set color transform when calling
 wlr_scene_output_build_state()

We were only passing the color transform when calling
wlr_scene_output_commit(). However when modesetting or pushing a
new gamma LUT we render via wlr_scene_output_build_state(). Pass
the color transform there as well.
---
 sway/config/output.c  | 1 +
 sway/desktop/output.c | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/sway/config/output.c b/sway/config/output.c
index bcd21b9b..16be49c8 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -927,6 +927,7 @@ bool apply_output_configs(struct matched_output_config *configs,
 		struct wlr_scene_output_state_options opts = {
 			.swapchain = wlr_output_swapchain_manager_get_swapchain(
 				&swapchain_mgr, backend_state->output),
+			.color_transform = cfg->output->color_transform,
 		};
 		struct wlr_scene_output *scene_output = cfg->output->scene_output;
 		struct wlr_output_state *state = &backend_state->base;
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index cfa53021..6bf77d17 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -243,10 +243,14 @@ static int output_repaint_timer_handler(void *data) {
 
 	output_configure_scene(output, &root->root_scene->tree.node, 1.0f);
 
+	struct wlr_scene_output_state_options opts = {
+		.color_transform = output->color_transform,
+	};
+
 	if (output->gamma_lut_changed) {
 		struct wlr_output_state pending;
 		wlr_output_state_init(&pending);
-		if (!wlr_scene_output_build_state(output->scene_output, &pending, NULL)) {
+		if (!wlr_scene_output_build_state(output->scene_output, &pending, &opts)) {
 			return 0;
 		}
 
@@ -269,9 +273,6 @@ static int output_repaint_timer_handler(void *data) {
 		return 0;
 	}
 
-	struct wlr_scene_output_state_options opts = {
-		.color_transform = output->color_transform,
-	};
 	wlr_scene_output_commit(output->scene_output, &opts);
 	return 0;
 }