head-management: add tearing-state-v1 extension
This commit is contained in:
parent
aaef75f9f3
commit
4482c3168b
10 changed files with 140 additions and 4 deletions
|
|
@ -80,6 +80,8 @@ pub struct HeadState {
|
|||
pub inherent_non_desktop: bool,
|
||||
pub override_non_desktop: Option<bool>,
|
||||
pub vrr: bool,
|
||||
pub tearing_enabled: bool,
|
||||
pub tearing_active: bool,
|
||||
}
|
||||
|
||||
impl HeadState {
|
||||
|
|
@ -380,4 +382,28 @@ impl HeadManagers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_tearing_enabled_change(&self, enabled: bool) {
|
||||
let state = &mut *self.state.borrow_mut();
|
||||
state.tearing_enabled = enabled;
|
||||
for head in self.managers.lock().values() {
|
||||
skip_in_transaction!(head);
|
||||
if let Some(ext) = &head.ext.tearing_state_v1 {
|
||||
ext.send_enabled(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_tearing_active_change(&self, active: bool) {
|
||||
let state = &mut *self.state.borrow_mut();
|
||||
state.tearing_active = active;
|
||||
for head in self.managers.lock().values() {
|
||||
skip_in_transaction!(head);
|
||||
if let Some(ext) = &head.ext.tearing_state_v1 {
|
||||
ext.send_active(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,4 +400,5 @@ declare_extensions! {
|
|||
physical_display_info_v1: PhysicalDisplayInfoV1,
|
||||
non_desktop_info_v1: NonDesktopInfoV1,
|
||||
vrr_state_v1: VrrStateV1,
|
||||
tearing_state_v1: TearingStateV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ 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;
|
||||
pub(super) mod jay_head_ext_physical_display_info_v1;
|
||||
pub(super) mod jay_head_ext_tearing_state_v1;
|
||||
pub(super) mod jay_head_ext_vrr_state_v1;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::HeadState,
|
||||
wire::{
|
||||
jay_head_ext_tearing_state_v1::{
|
||||
Active, Disabled, Enabled, Inactive, JayHeadExtTearingStateV1RequestHandler,
|
||||
},
|
||||
jay_head_manager_ext_tearing_state_v1::JayHeadManagerExtTearingStateV1RequestHandler,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
impl_tearing_state_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_active(shared);
|
||||
}
|
||||
|
||||
fn after_transaction(&self, shared: &HeadState, tran: &HeadState) {
|
||||
if shared.tearing_enabled != tran.tearing_enabled {
|
||||
self.send_enabled(shared);
|
||||
}
|
||||
if shared.tearing_active != tran.tearing_active {
|
||||
self.send_active(shared);
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_enabled(&self, state: &HeadState) {
|
||||
if state.tearing_enabled {
|
||||
self.client.event(Enabled { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(Disabled { self_id: self.id });
|
||||
}
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_active(&self, state: &HeadState) {
|
||||
if state.tearing_active {
|
||||
self.client.event(Active { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(Inactive { self_id: self.id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl JayHeadManagerExtTearingStateV1RequestHandler for MgrName {
|
||||
type Error = ErrorName;
|
||||
|
||||
mgr_common_req!();
|
||||
}
|
||||
|
||||
impl JayHeadExtTearingStateV1RequestHandler for HeadName {
|
||||
type Error = ErrorName;
|
||||
|
||||
head_common_req!();
|
||||
}
|
||||
|
||||
error!();
|
||||
Loading…
Add table
Add a link
Reference in a new issue