1
0
Fork 0
forked from wry/wry

head-management: add mode-info-v1 extension

This commit is contained in:
Julian Orth 2025-07-12 09:32:38 +02:00
parent e24ea33734
commit c25ddc8b5b
7 changed files with 83 additions and 0 deletions

View file

@ -218,6 +218,10 @@ impl HeadManagers {
ext.send_connected(state);
head.session.schedule_done();
}
if let Some(ext) = &head.ext.mode_info_v1 {
ext.send_mode(state);
head.session.schedule_done();
}
if let Some(ext) = &head.ext.compositor_space_info_v1 {
ext.send_inside_outside(state);
head.session.schedule_done();
@ -264,6 +268,10 @@ impl HeadManagers {
ext.send_size(state);
head.session.schedule_done();
}
if let Some(ext) = &head.ext.mode_info_v1 {
ext.send_mode(state);
head.session.schedule_done();
}
}
}

View file

@ -395,4 +395,5 @@ declare_extensions! {
compositor_space_scaler_v1: CompositorSpaceScalerV1,
compositor_space_enabler_v1: CompositorSpaceEnablerV1,
connector_info_v1: ConnectorInfoV1,
mode_info_v1: ModeInfoV1,
}

View file

@ -5,3 +5,4 @@ pub(super) mod jay_head_ext_compositor_space_scaler_v1;
pub(super) mod jay_head_ext_compositor_space_transformer_v1;
pub(super) mod jay_head_ext_connector_info_v1;
pub(super) mod jay_head_ext_core_info_v1;
pub(super) mod jay_head_ext_mode_info_v1;

View file

@ -0,0 +1,51 @@
use {
crate::{
ifs::head_management::HeadState,
wire::{
jay_head_ext_mode_info_v1::{JayHeadExtModeInfoV1RequestHandler, Mode},
jay_head_manager_ext_mode_info_v1::JayHeadManagerExtModeInfoV1RequestHandler,
},
},
std::rc::Rc,
};
impl_mode_info_v1! {
version = 1,
after_announce = after_announce,
after_transaction = after_transaction,
}
impl HeadName {
fn after_announce(&self, shared: &HeadState) {
self.send_mode(shared);
}
fn after_transaction(&self, shared: &HeadState, tran: &HeadState) {
if shared.mode != tran.mode {
self.send_mode(shared);
}
}
pub(in super::super) fn send_mode(&self, state: &HeadState) {
self.client.event(Mode {
self_id: self.id,
width: state.mode.width,
height: state.mode.height,
refresh_mhz: state.mode.refresh_rate_millihz,
})
}
}
impl JayHeadManagerExtModeInfoV1RequestHandler for MgrName {
type Error = ErrorName;
mgr_common_req!();
}
impl JayHeadExtModeInfoV1RequestHandler for HeadName {
type Error = ErrorName;
head_common_req!();
}
error!();

View file

@ -381,6 +381,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
COMPOSITOR_SPACE_INFO_SIZE = 1 << 3,
COMPOSITOR_SPACE_INFO_TRANSFORM = 1 << 4,
COMPOSITOR_SPACE_INFO_SCALE = 1 << 5,
MODE_INFO = 1 << 6,
COMPOSITOR_SPACE_INFO_ENABLED = 1 << 13,
}
for head in self.heads.lock().values() {
@ -441,6 +442,11 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
}
}
}
if to_send.contains(MODE_INFO)
&& let Some(i) = &head.ext.mode_info_v1
{
i.send_mode(state);
}
}
slf.schedule_transaction_result(req.result, None)?;
Ok(())