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
|
|
@ -654,6 +654,8 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
inherent_non_desktop: false,
|
||||
override_non_desktop: None,
|
||||
vrr: false,
|
||||
tearing_enabled: backend_state.tearing,
|
||||
tearing_active: false,
|
||||
};
|
||||
let connector_data = Rc::new(ConnectorData {
|
||||
id,
|
||||
|
|
@ -727,6 +729,7 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
tray_items: Default::default(),
|
||||
ext_workspace_groups: Default::default(),
|
||||
pinned: Default::default(),
|
||||
tearing: Default::default(),
|
||||
});
|
||||
let dummy_workspace = Rc::new(WorkspaceNode {
|
||||
id: state.node_ids.next(),
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
|
|
@ -456,6 +456,9 @@ impl ConnectorData {
|
|||
if old.vrr != s.vrr {
|
||||
self.head_managers.handle_vrr_change(s.vrr);
|
||||
}
|
||||
if old.tearing != s.tearing {
|
||||
self.head_managers.handle_tearing_enabled_change(s.tearing);
|
||||
}
|
||||
if let Some(output) = state.outputs.get(&self.connector.id())
|
||||
&& let Some(node) = &output.node
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ pub fn handle(state: &Rc<State>, connector: &Rc<dyn Connector>) {
|
|||
inherent_non_desktop: false,
|
||||
override_non_desktop: backend_state.non_desktop_override,
|
||||
vrr: backend_state.vrr,
|
||||
tearing_enabled: backend_state.tearing,
|
||||
tearing_active: false,
|
||||
};
|
||||
let data = Rc::new(ConnectorData {
|
||||
id,
|
||||
|
|
@ -240,6 +242,7 @@ impl ConnectorHandler {
|
|||
tray_items: Default::default(),
|
||||
ext_workspace_groups: Default::default(),
|
||||
pinned: Default::default(),
|
||||
tearing: Default::default(),
|
||||
});
|
||||
on.update_visible();
|
||||
on.update_rects();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use {
|
|||
ext_workspace_manager_v1::WorkspaceManagerId,
|
||||
},
|
||||
wp_content_type_v1::ContentType,
|
||||
wp_presentation_feedback::KIND_VSYNC,
|
||||
zwlr_layer_shell_v1::{BACKGROUND, BOTTOM, OVERLAY, TOP},
|
||||
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
||||
},
|
||||
|
|
@ -47,10 +48,10 @@ use {
|
|||
WorkspaceNodeId, walker::NodeVisitor,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt, event_listener::EventSource, hash_map_ext::HashMapExt,
|
||||
linkedlist::LinkedList, on_drop_event::OnDropEvent, scroller::Scroller,
|
||||
transform_ext::TransformExt,
|
||||
asyncevent::AsyncEvent, bitflags::BitflagsExt, clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, event_listener::EventSource,
|
||||
hash_map_ext::HashMapExt, linkedlist::LinkedList, on_drop_event::OnDropEvent,
|
||||
scroller::Scroller, transform_ext::TransformExt,
|
||||
},
|
||||
wire::{
|
||||
ExtImageCopyCaptureSessionV1Id, JayOutputId, JayScreencastId, ZwlrScreencopyFrameV1Id,
|
||||
|
|
@ -107,6 +108,7 @@ pub struct OutputNode {
|
|||
pub tray_items: LinkedList<Rc<dyn DynTrayItem>>,
|
||||
pub ext_workspace_groups: CopyHashMap<WorkspaceManagerId, Rc<ExtWorkspaceGroupHandleV1>>,
|
||||
pub pinned: LinkedList<Rc<dyn PinnedNode>>,
|
||||
pub tearing: Cell<bool>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
|
|
@ -218,6 +220,13 @@ impl OutputNode {
|
|||
if locked && let Some(lock) = self.state.lock.lock.get() {
|
||||
lock.check_locked()
|
||||
}
|
||||
let tearing = flags.not_contains(KIND_VSYNC);
|
||||
if self.tearing.replace(tearing) != tearing {
|
||||
self.global
|
||||
.connector
|
||||
.head_managers
|
||||
.handle_tearing_active_change(tearing);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_exclusive_zones(self: &Rc<Self>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue