commit 6fed1f9d8933588484e2303e53ac4270a417d78a
parent bac8c0f4d0a569ac9f63a2055bb8c886778dcf06
Author: Simon Ser <contact@emersion.fr>
Date: Sun, 26 Jan 2025 14:36:54 +0100
Add support for color-management-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4962
Diffstat:
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
@@ -65,7 +65,7 @@ pcre2 = dependency('libpcre2-8')
wayland_server = dependency('wayland-server', version: '>=1.21.0')
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
-wayland_protos = dependency('wayland-protocols', version: '>=1.24', default_options: ['tests=false'])
+wayland_protos = dependency('wayland-protocols', version: '>=1.41', default_options: ['tests=false'])
xkbcommon = dependency('xkbcommon', version: '>=1.5.0')
cairo = dependency('cairo')
pango = dependency('pango')
diff --git a/protocols/meson.build b/protocols/meson.build
@@ -9,6 +9,7 @@ wayland_scanner = find_program(
protocols = [
wl_protocol_dir / 'stable/tablet/tablet-v2.xml',
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
+ wl_protocol_dir / 'staging/color-management/color-management-v1.xml',
wl_protocol_dir / 'staging/content-type/content-type-v1.xml',
wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
wl_protocol_dir / 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
diff --git a/sway/server.c b/sway/server.c
@@ -10,6 +10,7 @@
#include <wlr/render/allocator.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_alpha_modifier_v1.h>
+#include <wlr/types/wlr_color_management_v1.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_content_type_v1.h>
#include <wlr/types/wlr_cursor_shape_v1.h>
@@ -443,6 +444,33 @@ bool server_init(struct sway_server *server) {
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape);
+ if (server->renderer->features.input_color_transform) {
+ const enum wp_color_manager_v1_render_intent render_intents[] = {
+ WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL,
+ };
+ const enum wp_color_manager_v1_transfer_function transfer_functions[] = {
+ WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
+ WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
+ WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
+ };
+ const enum wp_color_manager_v1_primaries primaries[] = {
+ WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
+ WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
+ };
+ wlr_color_manager_v1_create(server->wl_display, 1, &(struct wlr_color_manager_v1_options){
+ .features = {
+ .parametric = true,
+ .set_mastering_display_primaries = true,
+ },
+ .render_intents = render_intents,
+ .render_intents_len = sizeof(render_intents) / sizeof(render_intents[0]),
+ .transfer_functions = transfer_functions,
+ .transfer_functions_len = sizeof(transfer_functions) / sizeof(transfer_functions[0]),
+ .primaries = primaries,
+ .primaries_len = sizeof(primaries) / sizeof(primaries[0]),
+ });
+ }
+
wl_list_init(&server->pending_launcher_ctxs);
// Avoid using "wayland-0" as display socket