head-management: add compositor-space-info-v1 extension
This commit is contained in:
parent
8356dd5d5c
commit
67acc6d938
11 changed files with 312 additions and 4 deletions
|
|
@ -389,4 +389,5 @@ macro_rules! declare_extensions {
|
|||
|
||||
declare_extensions! {
|
||||
core_info_v1: CoreInfoV1,
|
||||
compositor_space_info_v1: CompositorSpaceInfoV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
pub(super) mod jay_head_ext_compositor_space_info_v1;
|
||||
pub(super) mod jay_head_ext_core_info_v1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,113 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::HeadState,
|
||||
utils::transform_ext::TransformExt,
|
||||
wire::{
|
||||
jay_head_ext_compositor_space_info_v1::{
|
||||
Disabled, Enabled, Inside, JayHeadExtCompositorSpaceInfoV1RequestHandler, Outside,
|
||||
Position, Scaling, Size, Transform,
|
||||
},
|
||||
jay_head_manager_ext_compositor_space_info_v1::JayHeadManagerExtCompositorSpaceInfoV1RequestHandler,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
impl_compositor_space_info_v1! {
|
||||
version = 1,
|
||||
after_announce = after_announce,
|
||||
after_transaction = after_transaction,
|
||||
}
|
||||
|
||||
impl HeadName {
|
||||
fn after_announce(&self, shared: &HeadState) {
|
||||
self.send_enabled(shared);
|
||||
self.send_inside_outside(shared);
|
||||
}
|
||||
|
||||
fn after_transaction(&self, shared: &HeadState, tran: &HeadState) {
|
||||
if shared.connector_enabled != tran.connector_enabled {
|
||||
self.send_enabled(shared);
|
||||
}
|
||||
if shared.in_compositor_space != tran.in_compositor_space {
|
||||
self.send_inside_outside(shared);
|
||||
} else if shared.in_compositor_space {
|
||||
if shared.position != tran.position {
|
||||
self.send_position(shared);
|
||||
}
|
||||
if shared.size != tran.size {
|
||||
self.send_size(shared);
|
||||
}
|
||||
if shared.transform != tran.transform {
|
||||
self.send_transform(shared);
|
||||
}
|
||||
if shared.scale != tran.scale {
|
||||
self.send_scale(shared);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_inside_outside(&self, state: &HeadState) {
|
||||
if state.in_compositor_space {
|
||||
self.client.event(Inside { self_id: self.id });
|
||||
self.send_position(state);
|
||||
self.send_size(state);
|
||||
self.send_transform(state);
|
||||
self.send_scale(state);
|
||||
} else {
|
||||
self.client.event(Outside { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_enabled(&self, state: &HeadState) {
|
||||
if state.connector_enabled {
|
||||
self.client.event(Enabled { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(Disabled { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_position(&self, state: &HeadState) {
|
||||
self.client.event(Position {
|
||||
self_id: self.id,
|
||||
x: state.position.0,
|
||||
y: state.position.1,
|
||||
});
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_size(&self, state: &HeadState) {
|
||||
self.client.event(Size {
|
||||
self_id: self.id,
|
||||
width: state.size.0,
|
||||
height: state.size.1,
|
||||
});
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_transform(&self, state: &HeadState) {
|
||||
self.client.event(Transform {
|
||||
self_id: self.id,
|
||||
transform: state.transform.to_wl() as _,
|
||||
});
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_scale(&self, state: &HeadState) {
|
||||
self.client.event(Scaling {
|
||||
self_id: self.id,
|
||||
scaling: state.scale.to_wl(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl JayHeadManagerExtCompositorSpaceInfoV1RequestHandler for MgrName {
|
||||
type Error = ErrorName;
|
||||
|
||||
mgr_common_req!();
|
||||
}
|
||||
|
||||
impl JayHeadExtCompositorSpaceInfoV1RequestHandler for HeadName {
|
||||
type Error = ErrorName;
|
||||
|
||||
head_common_req!();
|
||||
}
|
||||
|
||||
error!();
|
||||
|
|
@ -374,7 +374,13 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
}
|
||||
bitflags! {
|
||||
ToSend: u32;
|
||||
CORE_INFO = 1 << 0,
|
||||
CORE_INFO = 1 << 0,
|
||||
COMPOSITOR_SPACE_INFO_FULL = 1 << 1,
|
||||
COMPOSITOR_SPACE_INFO_POS = 1 << 2,
|
||||
COMPOSITOR_SPACE_INFO_SIZE = 1 << 3,
|
||||
COMPOSITOR_SPACE_INFO_TRANSFORM = 1 << 4,
|
||||
COMPOSITOR_SPACE_INFO_SCALE = 1 << 5,
|
||||
COMPOSITOR_SPACE_INFO_ENABLED = 1 << 13,
|
||||
}
|
||||
for head in self.heads.lock().values() {
|
||||
let pending = mem::take(&mut *head.common.pending.borrow_mut());
|
||||
|
|
@ -392,6 +398,27 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
{
|
||||
i.send_wl_output(state);
|
||||
}
|
||||
if let Some(i) = &head.ext.compositor_space_info_v1 {
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_ENABLED) {
|
||||
i.send_enabled(state);
|
||||
}
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_FULL) {
|
||||
i.send_inside_outside(state);
|
||||
} else {
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_POS) {
|
||||
i.send_position(state);
|
||||
}
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_SIZE) {
|
||||
i.send_size(state);
|
||||
}
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_TRANSFORM) {
|
||||
i.send_transform(state);
|
||||
}
|
||||
if to_send.contains(COMPOSITOR_SPACE_INFO_SCALE) {
|
||||
i.send_scale(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
slf.schedule_transaction_result(req.result, None)?;
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue