1
0
Fork 0
forked from wry/wry

head-management: add format-info-v1 extension

This commit is contained in:
Julian Orth 2025-07-13 14:09:50 +02:00
parent 4482c3168b
commit 1195613fc6
9 changed files with 84 additions and 0 deletions

View file

@ -2,6 +2,7 @@ use {
crate::{
backend::{ConnectorId, Mode, MonitorInfo, transaction::BackendConnectorTransactionError},
client::ClientId,
format::Format,
globals::GlobalName,
ifs::head_management::{
head_management_macros::HeadExts, jay_head_manager_session_v1::JayHeadManagerSessionV1,
@ -82,6 +83,7 @@ pub struct HeadState {
pub vrr: bool,
pub tearing_enabled: bool,
pub tearing_active: bool,
pub format: &'static Format,
}
impl HeadState {
@ -406,4 +408,16 @@ impl HeadManagers {
}
}
}
pub fn handle_format_change(&self, format: &'static Format) {
let state = &mut *self.state.borrow_mut();
state.format = format;
for head in self.managers.lock().values() {
skip_in_transaction!(head);
if let Some(ext) = &head.ext.format_info_v1 {
ext.send_format(state);
head.session.schedule_done();
}
}
}
}

View file

@ -401,4 +401,5 @@ declare_extensions! {
non_desktop_info_v1: NonDesktopInfoV1,
vrr_state_v1: VrrStateV1,
tearing_state_v1: TearingStateV1,
format_info_v1: FormatInfoV1,
}

View file

@ -5,6 +5,7 @@ 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_format_info_v1;
pub(super) mod jay_head_ext_mode_info_v1;
pub(super) mod jay_head_ext_mode_setter_v1;
pub(super) mod jay_head_ext_non_desktop_info_v1;

View file

@ -0,0 +1,49 @@
use {
crate::{
ifs::head_management::HeadState,
wire::{
jay_head_ext_format_info_v1::{Format, JayHeadExtFormatInfoV1RequestHandler},
jay_head_manager_ext_format_info_v1::JayHeadManagerExtFormatInfoV1RequestHandler,
},
},
std::rc::Rc,
};
impl_format_info_v1! {
version = 1,
after_announce = after_announce,
after_transaction = after_transaction,
}
impl HeadName {
fn after_announce(&self, shared: &HeadState) {
self.send_format(shared);
}
fn after_transaction(&self, shared: &HeadState, tran: &HeadState) {
if shared.format != tran.format {
self.send_format(shared);
}
}
pub(in super::super) fn send_format(&self, state: &HeadState) {
self.client.event(Format {
self_id: self.id,
format: state.format.drm,
});
}
}
impl JayHeadManagerExtFormatInfoV1RequestHandler for MgrName {
type Error = ErrorName;
mgr_common_req!();
}
impl JayHeadExtFormatInfoV1RequestHandler for HeadName {
type Error = ErrorName;
head_common_req!();
}
error!();