From ea4181a96147b29062c49185c2cd53762daafc87 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 26 Jan 2025 14:36:54 +0100 Subject: [PATCH] Add support for color-management-v1 References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4962 --- protocols/meson.build | 1 + sway/server.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/protocols/meson.build b/protocols/meson.build index 4d24e7071..3414119b8 100644 --- 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 index c7fc2a6df..039294646 100644 --- a/sway/server.c +++ b/sway/server.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -411,6 +412,30 @@ 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); + 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, + }; + 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