From 7873d1df1f2e8bffaa7da02f467f4e8cf247626a Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 4 Mar 2026 13:04:59 +0100 Subject: [PATCH] color-representation: advertise identity/full support --- .../wp_color_representation_surface_v1.rs | 18 ++++++++++++------ src/ifs/wp_color_representation_manager_v1.rs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ifs/wl_surface/wp_color_representation_surface_v1.rs b/src/ifs/wl_surface/wp_color_representation_surface_v1.rs index f4173fb7..6201874a 100644 --- a/src/ifs/wl_surface/wp_color_representation_surface_v1.rs +++ b/src/ifs/wl_surface/wp_color_representation_surface_v1.rs @@ -30,6 +30,9 @@ pub const AM_PREMULTIPLIED_ELECTRICAL: u32 = 0; pub const AM_PREMULTIPLIED_OPTICAL: u32 = 1; pub const AM_STRAIGHT: u32 = 2; +pub const COEF_IDENTITY: u32 = 1; +pub const RANGE_FULL: u32 = 1; + impl WpColorRepresentationSurfaceV1 { pub fn install(self: &Rc) -> Result<(), WpColorRepresentationSurfaceV1Error> { if self.surface.color_representation_surface.is_some() { @@ -71,12 +74,15 @@ impl WpColorRepresentationSurfaceV1RequestHandler for WpColorRepresentationSurfa req: SetCoefficientsAndRange, _slf: &Rc, ) -> Result<(), Self::Error> { - Err( - WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange( - req.coefficients, - req.range, - ), - ) + if (req.coefficients, req.range) != (COEF_IDENTITY, RANGE_FULL) { + return Err( + WpColorRepresentationSurfaceV1Error::UnsupportedCoefficientsAndRange( + req.coefficients, + req.range, + ), + ); + } + Ok(()) } fn set_chroma_location( diff --git a/src/ifs/wp_color_representation_manager_v1.rs b/src/ifs/wp_color_representation_manager_v1.rs index 9ebc7c15..006e843e 100644 --- a/src/ifs/wp_color_representation_manager_v1.rs +++ b/src/ifs/wp_color_representation_manager_v1.rs @@ -3,15 +3,15 @@ use { client::{Client, ClientError}, globals::{Global, GlobalName}, ifs::wl_surface::wp_color_representation_surface_v1::{ - AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT, - WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error, + AM_PREMULTIPLIED_ELECTRICAL, AM_PREMULTIPLIED_OPTICAL, AM_STRAIGHT, COEF_IDENTITY, + RANGE_FULL, WpColorRepresentationSurfaceV1, WpColorRepresentationSurfaceV1Error, }, leaks::Tracker, object::{Object, Version}, wire::{ WpColorRepresentationManagerV1Id, wp_color_representation_manager_v1::{ - Destroy, Done, GetSurface, SupportedAlphaMode, + Destroy, Done, GetSurface, SupportedAlphaMode, SupportedCoefficientsAndRanges, WpColorRepresentationManagerV1RequestHandler, }, }, @@ -70,6 +70,7 @@ impl WpColorRepresentationManagerV1 { self.send_supported_alpha_mode(AM_PREMULTIPLIED_OPTICAL); self.send_supported_alpha_mode(AM_STRAIGHT); } + self.send_supported_coefficients_and_ranges(COEF_IDENTITY, RANGE_FULL); self.send_done(); } @@ -80,6 +81,14 @@ impl WpColorRepresentationManagerV1 { }); } + fn send_supported_coefficients_and_ranges(&self, coefficients: u32, range: u32) { + self.client.event(SupportedCoefficientsAndRanges { + self_id: self.id, + coefficients, + range, + }); + } + fn send_done(&self) { self.client.event(Done { self_id: self.id }); }