1
0
Fork 0
forked from wry/wry

head-management: add compositor-space-enabler-v1 extension

This commit is contained in:
Julian Orth 2025-07-12 09:31:12 +02:00
parent 5636f6bda5
commit 51170cbde5
8 changed files with 78 additions and 3 deletions

View file

@ -139,7 +139,6 @@ pub trait Connector: Any {
fn damage(&self); fn damage(&self);
fn drm_dev(&self) -> Option<DrmDeviceId>; fn drm_dev(&self) -> Option<DrmDeviceId>;
fn effectively_locked(&self) -> bool; fn effectively_locked(&self) -> bool;
#[expect(dead_code)]
fn caps(&self) -> ConnectorCaps { fn caps(&self) -> ConnectorCaps {
ConnectorCaps::none() ConnectorCaps::none()
} }

View file

@ -103,6 +103,7 @@ impl HeadState {
enum HeadOp { enum HeadOp {
SetPosition(i32, i32), SetPosition(i32, i32),
SetConnectorEnabled(bool),
SetTransform(Transform), SetTransform(Transform),
SetScale(Scale), SetScale(Scale),
} }

View file

@ -393,4 +393,5 @@ declare_extensions! {
compositor_space_positioner_v1: CompositorSpacePositionerV1, compositor_space_positioner_v1: CompositorSpacePositionerV1,
compositor_space_transformer_v1: CompositorSpaceTransformerV1, compositor_space_transformer_v1: CompositorSpaceTransformerV1,
compositor_space_scaler_v1: CompositorSpaceScalerV1, compositor_space_scaler_v1: CompositorSpaceScalerV1,
compositor_space_enabler_v1: CompositorSpaceEnablerV1,
} }

View file

@ -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_info_v1;
pub(super) mod jay_head_ext_compositor_space_positioner_v1; pub(super) mod jay_head_ext_compositor_space_positioner_v1;
pub(super) mod jay_head_ext_compositor_space_scaler_v1; pub(super) mod jay_head_ext_compositor_space_scaler_v1;

View file

@ -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<HeadCommon>) -> 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<Self>) -> Result<(), Self::Error> {
self.common.push_op(HeadOp::SetConnectorEnabled(true))?;
Ok(())
}
fn disable(&self, _req: Disable, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.common.push_op(HeadOp::SetConnectorEnabled(false))?;
Ok(())
}
}
error!();

View file

@ -262,8 +262,8 @@ impl JayHeadManagerSessionV1 {
return Err(HeadTransactionError::HeadRemoved(head.common.id)); return Err(HeadTransactionError::HeadRemoved(head.common.id));
}; };
let old = connector.state.get(); let old = connector.state.get();
#[expect(unused_mut)]
let mut new = old; let mut new = old;
new.enabled = desired.connector_enabled;
if old == new { if old == new {
continue; continue;
} }
@ -385,7 +385,6 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
} }
for head in self.heads.lock().values() { for head in self.heads.lock().values() {
let pending = mem::take(&mut *head.common.pending.borrow_mut()); let pending = mem::take(&mut *head.common.pending.borrow_mut());
#[expect(unused_variables)]
let snapshot = &*head.common.snapshot_state.borrow(); let snapshot = &*head.common.snapshot_state.borrow();
let state = &mut *head.common.transaction_state.borrow_mut(); let state = &mut *head.common.transaction_state.borrow_mut();
let mut to_send = ToSend::default(); let mut to_send = ToSend::default();
@ -395,6 +394,13 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
state.position = (x, y); state.position = (x, y);
to_send |= COMPOSITOR_SPACE_INFO_POS; 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) => { HeadOp::SetTransform(t) => {
state.transform = t; state.transform = t;
state.update_size(); state.update_size();

View file

@ -0,0 +1,11 @@
request destroy (destructor) {
}
request enable {
}
request disable {
}

View file

@ -0,0 +1,7 @@
request destroy (destructor) {
}
event head {
head: id(jay_head_ext_compositor_space_enabler_v1) (new),
}