head-management: add compositor-space-positioner-v1 extension
This commit is contained in:
parent
67acc6d938
commit
a12b259648
7 changed files with 97 additions and 8 deletions
|
|
@ -94,7 +94,9 @@ impl HeadState {
|
|||
}
|
||||
}
|
||||
|
||||
enum HeadOp {}
|
||||
enum HeadOp {
|
||||
SetPosition(i32, i32),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
|
||||
enum HeadMgrState {
|
||||
|
|
@ -128,7 +130,6 @@ impl HeadCommon {
|
|||
}
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
fn push_op(&self, op: HeadOp) -> Result<(), HeadCommonError> {
|
||||
self.assert_in_transaction()?;
|
||||
self.pending.borrow_mut().push(op);
|
||||
|
|
|
|||
|
|
@ -390,4 +390,5 @@ macro_rules! declare_extensions {
|
|||
declare_extensions! {
|
||||
core_info_v1: CoreInfoV1,
|
||||
compositor_space_info_v1: CompositorSpaceInfoV1,
|
||||
compositor_space_positioner_v1: CompositorSpacePositionerV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
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_core_info_v1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
use {
|
||||
crate::{
|
||||
compositor::MAX_EXTENTS,
|
||||
ifs::head_management::{HeadOp, HeadState},
|
||||
wire::{
|
||||
jay_head_ext_compositor_space_positioner_v1::{
|
||||
JayHeadExtCompositorSpacePositionerV1RequestHandler, Range, SetPosition,
|
||||
},
|
||||
jay_head_manager_ext_compositor_space_positioner_v1::JayHeadManagerExtCompositorSpacePositionerV1RequestHandler,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
impl_compositor_space_positioner_v1! {
|
||||
version = 1,
|
||||
after_announce = after_announce,
|
||||
}
|
||||
|
||||
impl HeadName {
|
||||
fn after_announce(&self, _shared: &HeadState) {
|
||||
self.send_range();
|
||||
}
|
||||
|
||||
fn send_range(&self) {
|
||||
self.client.event(Range {
|
||||
self_id: self.id,
|
||||
x_min: 0,
|
||||
y_min: 0,
|
||||
x_max: MAX_EXTENTS,
|
||||
y_max: MAX_EXTENTS,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl JayHeadManagerExtCompositorSpacePositionerV1RequestHandler for MgrName {
|
||||
type Error = ErrorName;
|
||||
|
||||
mgr_common_req!();
|
||||
}
|
||||
|
||||
impl JayHeadExtCompositorSpacePositionerV1RequestHandler for HeadName {
|
||||
type Error = ErrorName;
|
||||
|
||||
head_common_req!();
|
||||
|
||||
fn set_position(&self, req: SetPosition, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.common.assert_in_transaction()?;
|
||||
if req.x < 0 || req.x > MAX_EXTENTS || req.y < 0 || req.y > MAX_EXTENTS {
|
||||
return Err(JayHeadExtCompositorSpacePositionerV1Error::PositionOutOfBounds);
|
||||
}
|
||||
self.common.push_op(HeadOp::SetPosition(req.x, req.y))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
error! {
|
||||
#[error("The position is out of bounds")]
|
||||
PositionOutOfBounds,
|
||||
}
|
||||
|
|
@ -5,7 +5,8 @@ use {
|
|||
client::{Client, ClientError},
|
||||
ifs::{
|
||||
head_management::{
|
||||
Head, HeadCommon, HeadCommonError, HeadMgrState, HeadName, HeadTransactionError,
|
||||
Head, HeadCommon, HeadCommonError, HeadMgrState, HeadName, HeadOp,
|
||||
HeadTransactionError,
|
||||
head_management_macros::{HeadExtension, MgrExts, announce_head, bind_extension},
|
||||
jay_head_manager_v1::JayHeadManagerV1,
|
||||
jay_head_transaction_result_v1::JayHeadTransactionResultV1,
|
||||
|
|
@ -387,11 +388,14 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
#[expect(unused_variables)]
|
||||
let snapshot = &*head.common.snapshot_state.borrow();
|
||||
let state = &mut *head.common.transaction_state.borrow_mut();
|
||||
#[expect(unused_mut)]
|
||||
let mut to_send = ToSend::default();
|
||||
#[expect(clippy::never_loop)]
|
||||
for op in pending {
|
||||
match op {}
|
||||
match op {
|
||||
HeadOp::SetPosition(x, y) => {
|
||||
state.position = (x, y);
|
||||
to_send |= COMPOSITOR_SPACE_INFO_POS;
|
||||
}
|
||||
}
|
||||
}
|
||||
if to_send.contains(CORE_INFO)
|
||||
&& let Some(i) = &head.ext.core_info_v1
|
||||
|
|
@ -451,7 +455,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
if let Some(output) = self.client.state.outputs.get(&head.common.id)
|
||||
&& let Some(node) = &output.node
|
||||
{
|
||||
let _ = node;
|
||||
node.set_position(desired.position.0, desired.position.1);
|
||||
} else if let Some(mi) = &desired.monitor_info {
|
||||
let pos = &self.client.state.persistent_output_states;
|
||||
let pos = match pos.get(&mi.output_id) {
|
||||
|
|
@ -470,7 +474,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
ps
|
||||
}
|
||||
};
|
||||
let _ = pos;
|
||||
pos.pos.set(desired.position);
|
||||
}
|
||||
}
|
||||
slf.schedule_transaction_result(req.result, None)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue