head-management: add non-desktop-info-v1 extension
This commit is contained in:
parent
81a7c973d0
commit
b76aade265
17 changed files with 164 additions and 5 deletions
|
|
@ -77,6 +77,8 @@ pub struct HeadState {
|
|||
pub transform: Transform,
|
||||
pub scale: Scale,
|
||||
pub monitor_info: Option<RcEq<MonitorInfo>>,
|
||||
pub inherent_non_desktop: bool,
|
||||
pub override_non_desktop: Option<bool>,
|
||||
}
|
||||
|
||||
impl HeadState {
|
||||
|
|
@ -92,6 +94,9 @@ impl HeadState {
|
|||
if mi.non_desktop {
|
||||
return;
|
||||
}
|
||||
if self.override_non_desktop == Some(true) {
|
||||
return;
|
||||
}
|
||||
self.in_compositor_space = true;
|
||||
self.wl_output = wl_output;
|
||||
}
|
||||
|
|
@ -206,6 +211,7 @@ impl HeadManagers {
|
|||
let state = &mut *self.state.borrow_mut();
|
||||
state.connected = true;
|
||||
state.monitor_info = Some(RcEq(output.monitor_info.clone()));
|
||||
state.inherent_non_desktop = output.monitor_info.non_desktop;
|
||||
state.update_in_compositor_space(output.node.as_ref().map(|n| n.global.name));
|
||||
if let Some(n) = &output.node {
|
||||
state.position = n.global.pos.get().position();
|
||||
|
|
@ -239,6 +245,10 @@ impl HeadManagers {
|
|||
ext.send_wl_output(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
if let Some(ext) = &head.ext.non_desktop_info_v1 {
|
||||
ext.send_state(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -337,4 +347,16 @@ impl HeadManagers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_non_desktop_override_changed(&self, overrd: Option<bool>) {
|
||||
let state = &mut *self.state.borrow_mut();
|
||||
state.override_non_desktop = overrd;
|
||||
for head in self.managers.lock().values() {
|
||||
skip_in_transaction!(head);
|
||||
if let Some(ext) = &head.ext.non_desktop_info_v1 {
|
||||
ext.send_state(state);
|
||||
head.session.schedule_done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,4 +398,5 @@ declare_extensions! {
|
|||
mode_info_v1: ModeInfoV1,
|
||||
mode_setter_v1: ModeSetterV1,
|
||||
physical_display_info_v1: PhysicalDisplayInfoV1,
|
||||
non_desktop_info_v1: NonDesktopInfoV1,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ 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;
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,78 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::head_management::HeadState,
|
||||
wire::{
|
||||
jay_head_ext_non_desktop_info_v1::{
|
||||
EffectiveDesktop, EffectiveNonDesktop, InherentDesktop, InherentNonDesktop,
|
||||
JayHeadExtNonDesktopInfoV1RequestHandler, OverrideDesktop, OverrideNonDesktop,
|
||||
Reset,
|
||||
},
|
||||
jay_head_manager_ext_non_desktop_info_v1::JayHeadManagerExtNonDesktopInfoV1RequestHandler,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
impl_non_desktop_info_v1! {
|
||||
version = 1,
|
||||
after_announce = after_announce,
|
||||
after_transaction = after_transaction,
|
||||
}
|
||||
|
||||
impl HeadName {
|
||||
fn after_announce(&self, shared: &HeadState) {
|
||||
self.send_state(shared);
|
||||
}
|
||||
|
||||
fn after_transaction(&self, shared: &HeadState, tran: &HeadState) {
|
||||
if shared.override_non_desktop == tran.override_non_desktop {
|
||||
match (&shared.monitor_info, &tran.monitor_info) {
|
||||
(Some(s), Some(t)) if s.non_desktop == t.non_desktop => return,
|
||||
(None, None) => return,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
self.send_state(shared);
|
||||
}
|
||||
|
||||
pub(in super::super) fn send_state(&self, state: &HeadState) {
|
||||
self.client.event(Reset { self_id: self.id });
|
||||
let mut inherent_non_desktop = None;
|
||||
if let Some(monitor_info) = &state.monitor_info {
|
||||
inherent_non_desktop = Some(monitor_info.non_desktop);
|
||||
if monitor_info.non_desktop {
|
||||
self.client.event(InherentNonDesktop { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(InherentDesktop { self_id: self.id });
|
||||
}
|
||||
}
|
||||
if let Some(overrd) = state.override_non_desktop {
|
||||
if overrd {
|
||||
self.client.event(OverrideNonDesktop { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(OverrideDesktop { self_id: self.id });
|
||||
}
|
||||
}
|
||||
if let Some(nd) = state.override_non_desktop.or(inherent_non_desktop) {
|
||||
if nd {
|
||||
self.client.event(EffectiveNonDesktop { self_id: self.id });
|
||||
} else {
|
||||
self.client.event(EffectiveDesktop { self_id: self.id });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl JayHeadManagerExtNonDesktopInfoV1RequestHandler for MgrName {
|
||||
type Error = ErrorName;
|
||||
|
||||
mgr_common_req!();
|
||||
}
|
||||
|
||||
impl JayHeadExtNonDesktopInfoV1RequestHandler for HeadName {
|
||||
type Error = ErrorName;
|
||||
|
||||
head_common_req!();
|
||||
}
|
||||
|
||||
error!();
|
||||
|
|
@ -50,7 +50,7 @@ impl HeadName {
|
|||
self.send_model(&mi.output_id.model);
|
||||
self.send_serial_number(&mi.output_id.serial_number);
|
||||
self.send_physical_size(mi.width_mm, mi.height_mm);
|
||||
if mi.non_desktop {
|
||||
if mi.non_desktop_effective {
|
||||
self.send_non_desktop();
|
||||
}
|
||||
if mi.vrr_capable {
|
||||
|
|
|
|||
|
|
@ -383,6 +383,7 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
COMPOSITOR_SPACE_INFO_TRANSFORM = 1 << 4,
|
||||
COMPOSITOR_SPACE_INFO_SCALE = 1 << 5,
|
||||
MODE_INFO = 1 << 6,
|
||||
NON_DESKTOP_INFO = 1 << 7,
|
||||
COMPOSITOR_SPACE_INFO_ENABLED = 1 << 13,
|
||||
}
|
||||
for head in self.heads.lock().values() {
|
||||
|
|
@ -454,6 +455,11 @@ impl JayHeadManagerSessionV1RequestHandler for JayHeadManagerSessionV1 {
|
|||
{
|
||||
i.send_mode(state);
|
||||
}
|
||||
if to_send.contains(NON_DESKTOP_INFO)
|
||||
&& let Some(i) = &head.ext.non_desktop_info_v1
|
||||
{
|
||||
i.send_state(state);
|
||||
}
|
||||
}
|
||||
slf.schedule_transaction_result(req.result, None)?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl WpDrmLeaseDeviceV1Global {
|
|||
}
|
||||
for c in dev.connectors.lock().keys() {
|
||||
if let Some(o) = client.state.outputs.get(c)
|
||||
&& o.monitor_info.non_desktop
|
||||
&& o.monitor_info.non_desktop_effective
|
||||
{
|
||||
obj.create_connector(&o);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue