Skip to content

Commit 5445fee

Browse files
committed
Add support for color-management-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4962
1 parent 9fc4ecc commit 5445fee

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pcre2 = dependency('libpcre2-8')
6565
wayland_server = dependency('wayland-server', version: '>=1.21.0')
6666
wayland_client = dependency('wayland-client')
6767
wayland_cursor = dependency('wayland-cursor')
68-
wayland_protos = dependency('wayland-protocols', version: '>=1.24', default_options: ['tests=false'])
68+
wayland_protos = dependency('wayland-protocols', version: '>=1.41', default_options: ['tests=false'])
6969
xkbcommon = dependency('xkbcommon', version: '>=1.5.0')
7070
cairo = dependency('cairo')
7171
pango = dependency('pango')

protocols/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ wayland_scanner = find_program(
99
protocols = [
1010
wl_protocol_dir / 'stable/tablet/tablet-v2.xml',
1111
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
12+
wl_protocol_dir / 'staging/color-management/color-management-v1.xml',
1213
wl_protocol_dir / 'staging/content-type/content-type-v1.xml',
1314
wl_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
1415
wl_protocol_dir / 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',

sway/server.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <wlr/render/allocator.h>
1111
#include <wlr/render/wlr_renderer.h>
1212
#include <wlr/types/wlr_alpha_modifier_v1.h>
13+
#include <wlr/types/wlr_color_management_v1.h>
1314
#include <wlr/types/wlr_compositor.h>
1415
#include <wlr/types/wlr_content_type_v1.h>
1516
#include <wlr/types/wlr_cursor_shape_v1.h>
@@ -443,6 +444,33 @@ bool server_init(struct sway_server *server) {
443444
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
444445
wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape);
445446

447+
if (server->renderer->features.input_color_transform) {
448+
const enum wp_color_manager_v1_render_intent render_intents[] = {
449+
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL,
450+
};
451+
const enum wp_color_manager_v1_transfer_function transfer_functions[] = {
452+
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
453+
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
454+
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR,
455+
};
456+
const enum wp_color_manager_v1_primaries primaries[] = {
457+
WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
458+
WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
459+
};
460+
wlr_color_manager_v1_create(server->wl_display, 1, &(struct wlr_color_manager_v1_options){
461+
.features = {
462+
.parametric = true,
463+
.set_mastering_display_primaries = true,
464+
},
465+
.render_intents = render_intents,
466+
.render_intents_len = sizeof(render_intents) / sizeof(render_intents[0]),
467+
.transfer_functions = transfer_functions,
468+
.transfer_functions_len = sizeof(transfer_functions) / sizeof(transfer_functions[0]),
469+
.primaries = primaries,
470+
.primaries_len = sizeof(primaries) / sizeof(primaries[0]),
471+
});
472+
}
473+
446474
wl_list_init(&server->pending_launcher_ctxs);
447475

448476
// Avoid using "wayland-0" as display socket

0 commit comments

Comments
 (0)