diff --git a/src/backend.rs b/src/backend.rs index 08b14ad2..7b5b6b73 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -139,7 +139,6 @@ pub trait Connector: Any { fn damage(&self); fn drm_dev(&self) -> Option; fn effectively_locked(&self) -> bool; - #[expect(dead_code)] fn caps(&self) -> ConnectorCaps { ConnectorCaps::none() } diff --git a/src/ifs/head_management.rs b/src/ifs/head_management.rs index 33b65fc9..a1e470fa 100644 --- a/src/ifs/head_management.rs +++ b/src/ifs/head_management.rs @@ -103,6 +103,7 @@ impl HeadState { enum HeadOp { SetPosition(i32, i32), + SetConnectorEnabled(bool), SetTransform(Transform), SetScale(Scale), } diff --git a/src/ifs/head_management/head_management_macros.rs b/src/ifs/head_management/head_management_macros.rs index dfc5a720..52d6c99a 100644 --- a/src/ifs/head_management/head_management_macros.rs +++ b/src/ifs/head_management/head_management_macros.rs @@ -393,4 +393,5 @@ declare_extensions! { compositor_space_positioner_v1: CompositorSpacePositionerV1, compositor_space_transformer_v1: CompositorSpaceTransformerV1, compositor_space_scaler_v1: CompositorSpaceScalerV1, + compositor_space_enabler_v1: CompositorSpaceEnablerV1, } diff --git a/src/ifs/head_management/jay_head_ext.rs b/src/ifs/head_management/jay_head_ext.rs index 9cdf85d8..2d5dda28 100644 --- a/src/ifs/head_management/jay_head_ext.rs +++ b/src/ifs/head_management/jay_head_ext.rs @@ -1,3 +1,4 @@ +pub(super) mod jay_head_ext_compositor_space_enabler_v1; pub(super) mod jay_head_ext_compositor_space_info_v1; pub(super) mod jay_head_ext_compositor_space_positioner_v1; pub(super) mod jay_head_ext_compositor_space_scaler_v1; diff --git a/src/ifs/head_management/jay_head_ext/jay_head_ext_compositor_space_enabler_v1.rs b/src/ifs/head_management/jay_head_ext/jay_head_ext_compositor_space_enabler_v1.rs new file mode 100644 index 00000000..75179c74 --- /dev/null +++ b/src/ifs/head_management/jay_head_ext/jay_head_ext_compositor_space_enabler_v1.rs @@ -0,0 +1,49 @@ +use { + crate::{ + backend::CONCAP_CONNECTOR, + ifs::head_management::{HeadCommon, HeadOp}, + state::ConnectorData, + wire::{ + jay_head_ext_compositor_space_enabler_v1::{ + Disable, Enable, JayHeadExtCompositorSpaceEnablerV1RequestHandler, + }, + jay_head_manager_ext_compositor_space_enabler_v1::JayHeadManagerExtCompositorSpaceEnablerV1RequestHandler, + }, + }, + std::rc::Rc, +}; + +impl_compositor_space_enabler_v1! { + version = 1, + filter = filter, +} + +impl MgrName { + fn filter(&self, connector: &ConnectorData, _common: &Rc) -> bool { + connector.connector.caps().contains(CONCAP_CONNECTOR) + } +} + +impl JayHeadManagerExtCompositorSpaceEnablerV1RequestHandler for MgrName { + type Error = ErrorName; + + mgr_common_req!(); +} + +impl JayHeadExtCompositorSpaceEnablerV1RequestHandler for HeadName { + type Error = ErrorName; + + head_common_req!(); + + fn enable(&self, _req: Enable, _slf: &Rc) -> Result<(), Self::Error> { + self.common.push_op(HeadOp::SetConnectorEnabled(true))?; + Ok(()) + } + + fn disable(&self, _req: Disable, _slf: &Rc) -> Result<(), Self::Error> { + self.common.push_op(HeadOp::SetConnectorEnabled(false))?; + Ok(()) + } +} + +error!(); diff --git a/src/ifs/head_management/jay_head_manager_session_v1.rs b/src/ifs/head_management/jay_head_manager_session_v1.rs index e8dc9fb7..cb6be4a7 100644 --- a/src/ifs/head_management/jay_head_manager_session_v1.rs +++ b/src/ifs/head_management/jay_head_manager_session_v1.rs @@ -262,8 +262,8 @@ impl JayHeadManagerSessionV1 { return Err(HeadTransactionError::HeadRemoved(head.common.id)); }; let old = connector.state.get(); - #[expect(unused_mut)] let mut new = old; + new.enabled = desired.connector_enabled; if old == new { continue; } @@ -385,7 +385,6 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 { } for head in self.heads.lock().values() { let pending = mem::take(&mut *head.common.pending.borrow_mut()); - #[expect(unused_variables)] let snapshot = &*head.common.snapshot_state.borrow(); let state = &mut *head.common.transaction_state.borrow_mut(); let mut to_send = ToSend::default(); @@ -395,6 +394,13 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 { state.position = (x, y); to_send |= COMPOSITOR_SPACE_INFO_POS; } + HeadOp::SetConnectorEnabled(enabled) => { + state.connector_enabled = enabled; + state.update_in_compositor_space(snapshot.wl_output); + to_send |= COMPOSITOR_SPACE_INFO_FULL; + to_send |= COMPOSITOR_SPACE_INFO_ENABLED; + to_send |= CORE_INFO; + } HeadOp::SetTransform(t) => { state.transform = t; state.update_size(); diff --git a/wire/jay_head_ext_compositor_space_enabler_v1.txt b/wire/jay_head_ext_compositor_space_enabler_v1.txt new file mode 100644 index 00000000..619bd395 --- /dev/null +++ b/wire/jay_head_ext_compositor_space_enabler_v1.txt @@ -0,0 +1,11 @@ +request destroy (destructor) { + +} + +request enable { + +} + +request disable { + +} diff --git a/wire/jay_head_manager_ext_compositor_space_enabler_v1.txt b/wire/jay_head_manager_ext_compositor_space_enabler_v1.txt new file mode 100644 index 00000000..b44c55a4 --- /dev/null +++ b/wire/jay_head_manager_ext_compositor_space_enabler_v1.txt @@ -0,0 +1,7 @@ +request destroy (destructor) { + +} + +event head { + head: id(jay_head_ext_compositor_space_enabler_v1) (new), +}