head-management: add jay-tearing-mode-info-v1 extension
This commit is contained in:
parent
3e2707174e
commit
a7f8a26df7
11 changed files with 107 additions and 11 deletions
|
|
@ -17,7 +17,7 @@ use {
|
|||
utils::{copyhashmap::CopyHashMap, hash_map_ext::HashMapExt, rc_eq::RcEq},
|
||||
wire::JayHeadManagerSessionV1Id,
|
||||
},
|
||||
jay_config::video::{Transform, VrrMode},
|
||||
jay_config::video::{TearingMode, Transform, VrrMode},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
rc::Rc,
|
||||
|
|
@ -87,6 +87,7 @@ pub struct HeadState {
|
|||
pub vrr_mode: VrrMode,
|
||||
pub tearing_enabled: bool,
|
||||
pub tearing_active: bool,
|
||||
pub tearing_mode: TearingMode,
|
||||
pub format: &'static Format,
|
||||
pub color_space: BackendColorSpace,
|
||||
pub transfer_function: BackendTransferFunction,
|
||||
|
|
@ -231,6 +232,7 @@ impl HeadManagers {
|
|||
state.mode = n.global.mode.get();
|
||||
state.transform = n.global.persistent.transform.get();
|
||||
state.vrr_mode = n.global.persistent.vrr_mode.get().to_config();
|
||||
state.tearing_mode = n.global.persistent.tearing_mode.get().to_config();
|
||||
}
|
||||
for head in self.managers.lock().values() {
|
||||
skip_in_transaction!(head);
|
||||
|
|
@ -270,6 +272,10 @@ impl HeadManagers {
|
|||
ext.send_mode(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
if let Some(ext) = &head.ext.jay_tearing_mode_info_v1 {
|
||||
ext.send_mode(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,6 +439,18 @@ impl HeadManagers {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_tearing_mode_change(&self, tearing_mode: TearingMode) {
|
||||
let state = &mut *self.state.borrow_mut();
|
||||
state.tearing_mode = tearing_mode;
|
||||
for head in self.managers.lock().values() {
|
||||
skip_in_transaction!(head);
|
||||
if let Some(ext) = &head.ext.jay_tearing_mode_info_v1 {
|
||||
ext.send_mode(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_format_change(&self, format: &'static Format) {
|
||||
let state = &mut *self.state.borrow_mut();
|
||||
state.format = format;
|
||||
|
|
|
|||
|
|
@ -405,4 +405,5 @@ declare_extensions! {
|
|||
drm_color_space_info_v1: DrmColorSpaceInfoV1,
|
||||
non_desktop_override_v1: NonDesktopOverrideV1,
|
||||
jay_vrr_mode_info_v1: JayVrrModeInfoV1,
|
||||
jay_tearing_mode_info_v1: JayTearingModeInfoV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub(super) mod jay_head_ext_connector_info_v1;
|
|||
pub(super) mod jay_head_ext_core_info_v1;
|
||||
pub(super) mod jay_head_ext_drm_color_space_info_v1;
|
||||
pub(super) mod jay_head_ext_format_info_v1;
|
||||
pub(super) mod jay_head_ext_jay_tearing_mode_info_v1;
|
||||
pub(super) mod jay_head_ext_jay_vrr_mode_info_v1;
|
||||
pub(super) mod jay_head_ext_mode_info_v1;
|
||||
pub(super) mod jay_head_ext_mode_setter_v1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::HeadState,
|
||||
wire::{
|
||||
jay_head_ext_jay_tearing_mode_info_v1::{
|
||||
JayHeadExtJayTearingModeInfoV1RequestHandler, Mode,
|
||||
},
|
||||
jay_head_manager_ext_jay_tearing_mode_info_v1::JayHeadManagerExtJayTearingModeInfoV1RequestHandler,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
impl_jay_tearing_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.tearing_mode != tran.tearing_mode {
|
||||
self.send_mode(shared);
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_mode(&self, state: &HeadState) {
|
||||
self.client.event(Mode {
|
||||
self_id: self.id,
|
||||
mode: state.tearing_mode.0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl JayHeadManagerExtJayTearingModeInfoV1RequestHandler for MgrName {
|
||||
type Error = ErrorName;
|
||||
|
||||
mgr_common_req!();
|
||||
}
|
||||
|
||||
impl JayHeadExtJayTearingModeInfoV1RequestHandler for HeadName {
|
||||
type Error = ErrorName;
|
||||
|
||||
head_common_req!();
|
||||
}
|
||||
|
||||
error!();
|
||||
|
|
@ -446,8 +446,7 @@ impl JayRandrRequestHandler for JayRandr {
|
|||
let Some(c) = self.get_output_node(req.output) else {
|
||||
return Ok(());
|
||||
};
|
||||
c.global.persistent.tearing_mode.set(mode);
|
||||
c.update_presentation_type();
|
||||
c.set_tearing_mode(mode);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue