config: allow disabling color-management
This commit is contained in:
parent
c66f5798b7
commit
248eb324a5
24 changed files with 388 additions and 9 deletions
|
|
@ -14,6 +14,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
state::State,
|
||||
wire::{
|
||||
WpColorManagerV1Id,
|
||||
wp_color_manager_v1::{SupportedIntent, *},
|
||||
|
|
@ -198,6 +199,10 @@ impl Global for WpColorManagerV1Global {
|
|||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
|
||||
fn exposed(&self, state: &State) -> bool {
|
||||
state.color_management_enabled.get()
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(WpColorManagerV1Global);
|
||||
|
|
|
|||
64
src/ifs/jay_color_management.rs
Normal file
64
src/ifs/jay_color_management.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{JayColorManagementId, jay_color_management::*},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct JayColorManagement {
|
||||
pub id: JayColorManagementId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl JayColorManagement {
|
||||
fn send_enabled(&self) {
|
||||
self.client.event(Enabled {
|
||||
self_id: self.id,
|
||||
enabled: self.client.state.color_management_enabled.get() as u32,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl JayColorManagementRequestHandler for JayColorManagement {
|
||||
type Error = JayColorManagementError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get(&self, _req: Get, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.send_enabled();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_enabled(&self, req: SetEnabled, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client
|
||||
.state
|
||||
.color_management_enabled
|
||||
.set(req.enabled != 0);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
self = JayColorManagement;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for JayColorManagement {}
|
||||
|
||||
simple_add_obj!(JayColorManagement);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum JayColorManagementError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(JayColorManagementError, ClientError);
|
||||
|
|
@ -4,6 +4,7 @@ use {
|
|||
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{
|
||||
jay_color_management::JayColorManagement,
|
||||
jay_ei_session_builder::JayEiSessionBuilder,
|
||||
jay_idle::JayIdle,
|
||||
jay_input::JayInput,
|
||||
|
|
@ -72,7 +73,7 @@ impl Global for JayCompositorGlobal {
|
|||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
13
|
||||
14
|
||||
}
|
||||
|
||||
fn required_caps(&self) -> ClientCaps {
|
||||
|
|
@ -439,6 +440,22 @@ impl JayCompositorRequestHandler for JayCompositor {
|
|||
obj.done(tl);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_color_management(
|
||||
&self,
|
||||
req: GetColorManagement,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let obj = Rc::new(JayColorManagement {
|
||||
id: req.id,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, obj);
|
||||
self.client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue