Skip to content

Commit 3e3cb31

Browse files
committed
wp-color-management-v1: update to version 2
1 parent 5090b45 commit 3e3cb31

12 files changed

+143
-23
lines changed

docs/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Jay supports the following wayland protocols:
174174
| wl_shm | 2 | |
175175
| wl_subcompositor | 1 | |
176176
| wp_alpha_modifier_v1 | 1 | |
177-
| wp_color_manager_v1 | 1 | |
177+
| wp_color_manager_v1 | 2 | |
178178
| wp_commit_timing_manager_v1 | 1 | |
179179
| wp_content_type_manager_v1 | 1 | |
180180
| wp_cursor_shape_manager_v1 | 2 | |

src/client/objects.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use {
22
crate::{
33
client::{Client, ClientError},
44
ifs::{
5-
color_management::wp_image_description_v1::WpImageDescriptionV1,
5+
color_management::{
6+
wp_image_description_reference_v1::WpImageDescriptionReferenceV1,
7+
wp_image_description_v1::WpImageDescriptionV1,
8+
},
69
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
710
ext_image_capture_source_v1::ExtImageCaptureSourceV1,
811
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
@@ -48,10 +51,11 @@ use {
4851
ExtImageCopyCaptureSessionV1Id, ExtWorkspaceGroupHandleV1Id, JayHeadErrorV1Id,
4952
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
5053
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
51-
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionV1Id,
52-
WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId, XdgSurfaceId,
53-
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwlrOutputHeadV1Id,
54-
ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
54+
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpImageDescriptionReferenceV1Id,
55+
WpImageDescriptionV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId, XdgPositionerId,
56+
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
57+
ZwlrOutputHeadV1Id, ZwlrOutputModeV1Id, ZwpPrimarySelectionSourceV1Id,
58+
ZwpTabletToolV2Id,
5559
},
5660
},
5761
std::{cell::RefCell, rc::Rc},
@@ -94,6 +98,8 @@ pub struct Objects {
9498
pub ext_workspace_groups:
9599
CopyHashMap<ExtWorkspaceGroupHandleV1Id, Rc<ExtWorkspaceGroupHandleV1>>,
96100
pub wp_image_description: CopyHashMap<WpImageDescriptionV1Id, Rc<WpImageDescriptionV1>>,
101+
pub wp_image_description_reference:
102+
CopyHashMap<WpImageDescriptionReferenceV1Id, Rc<WpImageDescriptionReferenceV1>>,
97103
pub jay_head_errors: CopyHashMap<JayHeadErrorV1Id, Rc<JayHeadErrorV1>>,
98104
ids: RefCell<Vec<usize>>,
99105
}
@@ -136,6 +142,7 @@ impl Objects {
136142
ext_data_sources: Default::default(),
137143
ext_workspace_groups: Default::default(),
138144
wp_image_description: Default::default(),
145+
wp_image_description_reference: Default::default(),
139146
jay_head_errors: Default::default(),
140147
ids: RefCell::new(vec![]),
141148
}
@@ -182,6 +189,8 @@ impl Objects {
182189
self.ext_data_sources.clear();
183190
self.ext_workspace_groups.clear();
184191
self.jay_head_errors.clear();
192+
self.wp_image_description.clear();
193+
self.wp_image_description_reference.clear();
185194
}
186195

187196
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>

src/ifs/color_management.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::object::Version;
12
pub use consts::*;
23

34
pub mod wp_color_management_output_v1;
@@ -6,8 +7,12 @@ pub mod wp_color_manager_v1;
67
pub mod wp_image_description_creator_icc_v1;
78
pub mod wp_image_description_creator_params_v1;
89
pub mod wp_image_description_info_v1;
10+
pub mod wp_image_description_reference_v1;
911
pub mod wp_image_description_v1;
1012

13+
const UNIQUE_CM_IDS_SINCE: Version = Version(2);
14+
const SRGB_DEPRECATED_SINCE: Version = Version(2);
15+
1116
const PRIMARIES_MUL: f64 = 1_000_000.0;
1217
const PRIMARIES_MUL_INV: f64 = 1.0 / PRIMARIES_MUL;
1318

@@ -55,6 +60,7 @@ mod consts {
5560
pub const TRANSFER_FUNCTION_ST2084_PQ: u32 = 11;
5661
pub const TRANSFER_FUNCTION_ST428: u32 = 12;
5762
pub const TRANSFER_FUNCTION_HLG: u32 = 13;
63+
pub const TRANSFER_FUNCTION_COMPOUND_POWER_2_4: u32 = 14;
5864

5965
pub const CAUSE_LOW_VERSION: u32 = 0;
6066
pub const CAUSE_UNSUPPORTED: u32 = 1;

src/ifs/color_management/wp_color_management_surface_feedback_v1.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use {
33
client::{Client, ClientError},
44
cmm::cmm_description::ColorDescription,
55
ifs::{
6-
color_management::wp_image_description_v1::WpImageDescriptionV1, wl_surface::WlSurface,
6+
color_management::{
7+
UNIQUE_CM_IDS_SINCE, wp_image_description_v1::WpImageDescriptionV1,
8+
},
9+
wl_surface::WlSurface,
710
},
811
leaks::Tracker,
912
object::{Object, Version},
@@ -43,10 +46,18 @@ impl WpColorManagementSurfaceFeedbackV1 {
4346
}
4447

4548
pub fn send_preferred_changed(&self, cd: &ColorDescription) {
46-
self.client.event(PreferredChanged {
47-
self_id: self.id,
48-
identity: cd.id.raw() as u32,
49-
});
49+
let identity = cd.id.raw();
50+
if self.version >= UNIQUE_CM_IDS_SINCE {
51+
self.client.event(PreferredChanged2 {
52+
self_id: self.id,
53+
identity,
54+
});
55+
} else {
56+
self.client.event(PreferredChanged {
57+
self_id: self.id,
58+
identity: identity as u32,
59+
});
60+
}
5061
}
5162
}
5263

src/ifs/color_management/wp_color_manager_v1.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use {
55
ifs::{
66
color_management::{
77
FEATURE_EXTENDED_TARGET_VOLUME, FEATURE_SET_MASTERING_DISPLAY_PRIMARIES,
8-
FEATURE_SET_TF_POWER,
8+
FEATURE_SET_TF_POWER, SRGB_DEPRECATED_SINCE,
99
consts::{
1010
FEATURE_PARAMETRIC, FEATURE_SET_LUMINANCES, FEATURE_SET_PRIMARIES,
1111
FEATURE_WINDOWS_SCRGB, PRIMARIES_ADOBE_RGB, PRIMARIES_BT2020,
@@ -90,8 +90,10 @@ impl WpColorManagerV1 {
9090
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_LINEAR);
9191
self.send_supported_tf_named(TRANSFER_FUNCTION_LOG_100);
9292
self.send_supported_tf_named(TRANSFER_FUNCTION_LOG_316);
93-
self.send_supported_tf_named(TRANSFER_FUNCTION_SRGB);
94-
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_SRGB);
93+
if self.version < SRGB_DEPRECATED_SINCE {
94+
self.send_supported_tf_named(TRANSFER_FUNCTION_SRGB);
95+
self.send_supported_tf_named(TRANSFER_FUNCTION_EXT_SRGB);
96+
}
9597
self.send_supported_tf_named(TRANSFER_FUNCTION_ST2084_PQ);
9698
self.send_supported_tf_named(TRANSFER_FUNCTION_ST428);
9799
self.send_supported_primaries_named(PRIMARIES_SRGB);
@@ -249,6 +251,25 @@ impl WpColorManagerV1RequestHandler for WpColorManagerV1 {
249251
obj.send_ready();
250252
Ok(())
251253
}
254+
255+
fn get_image_description(
256+
&self,
257+
req: GetImageDescription,
258+
_slf: &Rc<Self>,
259+
) -> Result<(), Self::Error> {
260+
let desc = self.client.lookup(req.reference)?;
261+
let obj = Rc::new(WpImageDescriptionV1 {
262+
id: req.image_description,
263+
client: self.client.clone(),
264+
version: self.version,
265+
tracker: Default::default(),
266+
description: Some(desc.description.clone()),
267+
});
268+
track!(self.client, obj);
269+
self.client.add_client_obj(&obj)?;
270+
obj.send_ready();
271+
Ok(())
272+
}
252273
}
253274

254275
global_base!(
@@ -263,7 +284,7 @@ impl Global for WpColorManagerV1Global {
263284
}
264285

265286
fn version(&self) -> u32 {
266-
1
287+
2
267288
}
268289

269290
fn exposed(&self, state: &State) -> bool {

src/ifs/color_management/wp_image_description_creator_params_v1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use {
77
cmm_primaries::{NamedPrimaries, Primaries},
88
},
99
ifs::color_management::{
10-
MIN_LUM_MUL_INV, PRIMARIES_MUL_INV,
10+
MIN_LUM_MUL_INV, PRIMARIES_MUL_INV, SRGB_DEPRECATED_SINCE,
1111
consts::{
1212
PRIMARIES_ADOBE_RGB, PRIMARIES_BT2020, PRIMARIES_CIE1931_XYZ, PRIMARIES_DCI_P3,
1313
PRIMARIES_DISPLAY_P3, PRIMARIES_GENERIC_FILM, PRIMARIES_NTSC, PRIMARIES_PAL,
@@ -116,8 +116,8 @@ impl WpImageDescriptionCreatorParamsV1RequestHandler for WpImageDescriptionCreat
116116
TRANSFER_FUNCTION_EXT_LINEAR => Eotf::Linear,
117117
TRANSFER_FUNCTION_LOG_100 => Eotf::Log100,
118118
TRANSFER_FUNCTION_LOG_316 => Eotf::Log316,
119-
TRANSFER_FUNCTION_SRGB => Eotf::Gamma22,
120-
TRANSFER_FUNCTION_EXT_SRGB => Eotf::Gamma22,
119+
TRANSFER_FUNCTION_SRGB if self.version < SRGB_DEPRECATED_SINCE => Eotf::Gamma22,
120+
TRANSFER_FUNCTION_EXT_SRGB if self.version < SRGB_DEPRECATED_SINCE => Eotf::Gamma22,
121121
TRANSFER_FUNCTION_ST2084_PQ => Eotf::St2084Pq,
122122
TRANSFER_FUNCTION_ST428 => Eotf::St428,
123123
_ => {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use {
2+
crate::{
3+
client::{Client, ClientError},
4+
cmm::cmm_description::ColorDescription,
5+
leaks::Tracker,
6+
object::{Object, Version},
7+
wire::{WpImageDescriptionReferenceV1Id, wp_image_description_reference_v1::*},
8+
},
9+
std::rc::Rc,
10+
thiserror::Error,
11+
};
12+
13+
#[expect(dead_code)]
14+
pub struct WpImageDescriptionReferenceV1 {
15+
pub id: WpImageDescriptionReferenceV1Id,
16+
pub client: Rc<Client>,
17+
pub tracker: Tracker<Self>,
18+
pub description: Rc<ColorDescription>,
19+
}
20+
21+
impl WpImageDescriptionReferenceV1RequestHandler for WpImageDescriptionReferenceV1 {
22+
type Error = WpImageDescriptionReferenceV1Error;
23+
24+
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
25+
self.client.remove_obj(self)?;
26+
Ok(())
27+
}
28+
}
29+
30+
object_base! {
31+
self = WpImageDescriptionReferenceV1;
32+
version = Version(1);
33+
}
34+
35+
impl Object for WpImageDescriptionReferenceV1 {}
36+
37+
dedicated_add_obj!(
38+
WpImageDescriptionReferenceV1,
39+
WpImageDescriptionReferenceV1Id,
40+
wp_image_description_reference
41+
);
42+
43+
#[derive(Debug, Error)]
44+
pub enum WpImageDescriptionReferenceV1Error {
45+
#[error(transparent)]
46+
ClientError(Box<ClientError>),
47+
}
48+
efrom!(WpImageDescriptionReferenceV1Error, ClientError);

src/ifs/color_management/wp_image_description_v1.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use {
22
crate::{
33
client::{Client, ClientError},
44
cmm::cmm_description::ColorDescription,
5-
ifs::color_management::wp_image_description_info_v1::WpImageDescriptionInfoV1,
5+
ifs::color_management::{
6+
UNIQUE_CM_IDS_SINCE, wp_image_description_info_v1::WpImageDescriptionInfoV1,
7+
},
68
leaks::Tracker,
79
object::{Object, Version},
810
wire::{WpImageDescriptionV1Id, wp_image_description_v1::*},
@@ -29,10 +31,18 @@ impl WpImageDescriptionV1 {
2931
}
3032

3133
pub fn send_ready(&self) {
32-
self.client.event(Ready {
33-
self_id: self.id,
34-
identity: self.description.as_ref().unwrap().id.raw() as u32,
35-
});
34+
let identity = self.description.as_ref().unwrap().id.raw();
35+
if self.version >= UNIQUE_CM_IDS_SINCE {
36+
self.client.event(Ready2 {
37+
self_id: self.id,
38+
identity,
39+
});
40+
} else {
41+
self.client.event(Ready {
42+
self_id: self.id,
43+
identity: identity as u32,
44+
});
45+
}
3646
}
3747
}
3848

wire/wp_color_management_surface_feedback_v1.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ request get_preferred {
1212
request get_preferred_parametric {
1313
image_description: id(wp_image_description_v1) (new),
1414
}
15+
16+
event preferred_changed2 (since = 2) {
17+
identity: u64,
18+
}

wire/wp_color_manager_v1.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ event supported_primaries_named {
4646

4747
event done {
4848
}
49+
50+
request get_image_description (since = 2) {
51+
image_description: id(wp_image_description_v1) (new),
52+
reference: id(wp_image_description_reference_v1),
53+
}

0 commit comments

Comments
 (0)