Skip to content

Commit 2c3c89e

Browse files
committed
Add support for color-management-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4962
1 parent 3c13649 commit 2c3c89e

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pcre2 = dependency('libpcre2-8')
6464
wayland_server = dependency('wayland-server', version: '>=1.21.0')
6565
wayland_client = dependency('wayland-client')
6666
wayland_cursor = dependency('wayland-cursor')
67-
wayland_protos = dependency('wayland-protocols', version: '>=1.24', default_options: ['tests=false'])
67+
wayland_protos = dependency('wayland-protocols', version: '>=1.41', default_options: ['tests=false'])
6868
xkbcommon = dependency('xkbcommon', version: '>=1.5.0')
6969
cairo = dependency('cairo')
7070
pango = dependency('pango')

protocols/meson.build

+1
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

+25
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>
@@ -411,6 +412,30 @@ bool server_init(struct sway_server *server) {
411412
server->request_set_cursor_shape.notify = handle_request_set_cursor_shape;
412413
wl_signal_add(&cursor_shape_manager->events.request_set_shape, &server->request_set_cursor_shape);
413414

415+
const enum wp_color_manager_v1_render_intent render_intents[] = {
416+
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL,
417+
};
418+
const enum wp_color_manager_v1_transfer_function transfer_functions[] = {
419+
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
420+
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
421+
};
422+
const enum wp_color_manager_v1_primaries primaries[] = {
423+
WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
424+
WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
425+
};
426+
wlr_color_manager_v1_create(server->wl_display, 1, &(struct wlr_color_manager_v1_options){
427+
.features = {
428+
.parametric = true,
429+
.set_mastering_display_primaries = true,
430+
},
431+
.render_intents = render_intents,
432+
.render_intents_len = sizeof(render_intents) / sizeof(render_intents[0]),
433+
.transfer_functions = transfer_functions,
434+
.transfer_functions_len = sizeof(transfer_functions) / sizeof(transfer_functions[0]),
435+
.primaries = primaries,
436+
.primaries_len = sizeof(primaries) / sizeof(primaries[0]),
437+
});
438+
414439
wl_list_init(&server->pending_launcher_ctxs);
415440

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

0 commit comments

Comments
 (0)