config: allow disabling color-management
This commit is contained in:
parent
c66f5798b7
commit
248eb324a5
24 changed files with 388 additions and 9 deletions
|
|
@ -1,4 +1,5 @@
|
|||
mod color;
|
||||
mod color_management;
|
||||
mod damage_tracking;
|
||||
mod duration;
|
||||
mod generate;
|
||||
|
|
@ -17,8 +18,8 @@ mod xwayland;
|
|||
use {
|
||||
crate::{
|
||||
cli::{
|
||||
damage_tracking::DamageTrackingArgs, idle::IdleCmd, input::InputArgs, randr::RandrArgs,
|
||||
xwayland::XwaylandArgs,
|
||||
color_management::ColorManagementArgs, damage_tracking::DamageTrackingArgs,
|
||||
idle::IdleCmd, input::InputArgs, randr::RandrArgs, xwayland::XwaylandArgs,
|
||||
},
|
||||
compositor::start_compositor,
|
||||
format::{Format, ref_formats},
|
||||
|
|
@ -78,6 +79,8 @@ pub enum Cmd {
|
|||
DamageTracking(DamageTrackingArgs),
|
||||
/// Inspect/modify xwayland settings.
|
||||
Xwayland(XwaylandArgs),
|
||||
/// Inspect/modify the color-management settings.
|
||||
ColorManagement(ColorManagementArgs),
|
||||
#[cfg(feature = "it")]
|
||||
RunTests,
|
||||
}
|
||||
|
|
@ -235,6 +238,7 @@ pub fn main() {
|
|||
Cmd::Input(a) => input::main(cli.global, a),
|
||||
Cmd::DamageTracking(a) => damage_tracking::main(cli.global, a),
|
||||
Cmd::Xwayland(a) => xwayland::main(cli.global, a),
|
||||
Cmd::ColorManagement(a) => color_management::main(cli.global, a),
|
||||
#[cfg(feature = "it")]
|
||||
Cmd::RunTests => crate::it::run_tests(),
|
||||
}
|
||||
|
|
|
|||
75
src/cli/color_management.rs
Normal file
75
src/cli/color_management.rs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
use {
|
||||
crate::{
|
||||
cli::GlobalArgs,
|
||||
tools::tool_client::{Handle, ToolClient, with_tool_client},
|
||||
wire::{JayColorManagementId, jay_color_management, jay_compositor},
|
||||
},
|
||||
clap::{Args, Subcommand},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct ColorManagementArgs {
|
||||
#[clap(subcommand)]
|
||||
pub command: Option<ColorManagementCmd>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug, Default)]
|
||||
pub enum ColorManagementCmd {
|
||||
/// Print the color-management status.
|
||||
#[default]
|
||||
Status,
|
||||
/// Enable the color-management protocol.
|
||||
Enable,
|
||||
/// Disable the color-management protocol.
|
||||
Disable,
|
||||
}
|
||||
|
||||
pub fn main(global: GlobalArgs, args: ColorManagementArgs) {
|
||||
with_tool_client(global.log_level.into(), |tc| async move {
|
||||
let cm = ColorManagement { tc: tc.clone() };
|
||||
cm.run(args).await;
|
||||
});
|
||||
}
|
||||
|
||||
struct ColorManagement {
|
||||
tc: Rc<ToolClient>,
|
||||
}
|
||||
|
||||
impl ColorManagement {
|
||||
async fn run(self, args: ColorManagementArgs) {
|
||||
let tc = &self.tc;
|
||||
let comp = tc.jay_compositor().await;
|
||||
let id = tc.id();
|
||||
tc.send(jay_compositor::GetColorManagement { self_id: comp, id });
|
||||
match args.command.unwrap_or_default() {
|
||||
ColorManagementCmd::Status => self.status(id).await,
|
||||
ColorManagementCmd::Enable => self.set_enabled(id, true).await,
|
||||
ColorManagementCmd::Disable => self.set_enabled(id, false).await,
|
||||
}
|
||||
}
|
||||
|
||||
async fn status(self, id: JayColorManagementId) {
|
||||
let tc = &self.tc;
|
||||
tc.send(jay_color_management::Get { self_id: id });
|
||||
let enabled = Rc::new(Cell::new(false));
|
||||
jay_color_management::Enabled::handle(tc, id, enabled.clone(), |iv, msg| {
|
||||
iv.set(msg.enabled != 0);
|
||||
});
|
||||
tc.round_trip().await;
|
||||
if enabled.get() {
|
||||
println!("Enabled");
|
||||
} else {
|
||||
println!("Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
async fn set_enabled(self, id: JayColorManagementId, enabled: bool) {
|
||||
let tc = &self.tc;
|
||||
tc.send(jay_color_management::SetEnabled {
|
||||
self_id: id,
|
||||
enabled: enabled as _,
|
||||
});
|
||||
tc.round_trip().await;
|
||||
}
|
||||
}
|
||||
|
|
@ -283,6 +283,7 @@ fn start_compositor2(
|
|||
tray_item_ids: Default::default(),
|
||||
data_control_device_ids: Default::default(),
|
||||
workspace_managers: Default::default(),
|
||||
color_management_enabled: Cell::new(false),
|
||||
});
|
||||
state.tracker.register(ClientId::from_raw(0));
|
||||
create_dummy_output(&state);
|
||||
|
|
|
|||
|
|
@ -926,6 +926,10 @@ impl ConfigProxyHandler {
|
|||
self.state.explicit_sync_enabled.set(enabled);
|
||||
}
|
||||
|
||||
fn handle_set_color_management_enabled(&self, enabled: bool) {
|
||||
self.state.color_management_enabled.set(enabled);
|
||||
}
|
||||
|
||||
fn handle_get_socket_path(&self) {
|
||||
match self.state.acceptor.get() {
|
||||
Some(a) => {
|
||||
|
|
@ -1986,6 +1990,9 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::SetIdleGracePeriod { period } => {
|
||||
self.handle_set_idle_grace_period(period)
|
||||
}
|
||||
ClientMessage::SetColorManagementEnabled { enabled } => {
|
||||
self.handle_set_color_management_enabled(enabled)
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,10 @@ pub trait Global: GlobalBase {
|
|||
fn xwayland_only(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn exposed(&self, state: &State) -> bool {
|
||||
let _ = state;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Globals {
|
||||
|
|
@ -297,7 +301,8 @@ impl Globals {
|
|||
($singleton:expr) => {
|
||||
for global in globals.values() {
|
||||
if global.singleton() == $singleton {
|
||||
if caps.contains(global.required_caps())
|
||||
if global.exposed(®istry.client.state)
|
||||
&& caps.contains(global.required_caps())
|
||||
&& (xwayland || !global.xwayland_only())
|
||||
{
|
||||
registry.send_global(global);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ pub mod ext_output_image_capture_source_manager_v1;
|
|||
pub mod ext_session_lock_manager_v1;
|
||||
pub mod ext_session_lock_v1;
|
||||
pub mod ipc;
|
||||
pub mod jay_color_management;
|
||||
pub mod jay_compositor;
|
||||
pub mod jay_damage_tracking;
|
||||
pub mod jay_ei_session;
|
||||
|
|
|
|||
|
|
@ -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! {
|
||||
|
|
|
|||
|
|
@ -233,6 +233,7 @@ pub struct State {
|
|||
pub tray_item_ids: TrayItemIds,
|
||||
pub data_control_device_ids: DataControlDeviceIds,
|
||||
pub workspace_managers: WorkspaceManagerState,
|
||||
pub color_management_enabled: Cell<bool>,
|
||||
}
|
||||
|
||||
// impl Drop for State {
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ impl ToolClient {
|
|||
self_id: s.registry,
|
||||
name: s.jay_compositor.0,
|
||||
interface: JayCompositor.name(),
|
||||
version: s.jay_compositor.1.min(13),
|
||||
version: s.jay_compositor.1.min(14),
|
||||
id: id.into(),
|
||||
});
|
||||
self.jay_compositor.set(Some(id));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue