fix: exclude shared host desktop bookkeeping from visual dependencies

This commit is contained in:
2026-10-24 01:55:27 +08:00
parent 9bb61befd8
commit ae3a2d6163
3 changed files with 38 additions and 3 deletions
+29 -3
View File
@@ -236,6 +236,15 @@ struct Session {
exiting: bool,
}
impl Session {
fn host_desktops(&self) -> std::collections::HashSet<ObjectRef> {
self.presentations
.values()
.map(|view| view.desktop)
.collect()
}
}
impl std::ops::Deref for Session {
type Target = crate::presentation::Presentation;
fn deref(&self) -> &Self::Target {
@@ -2612,11 +2621,18 @@ impl UiBridge {
progress: crate::source_paint::Progress,
) -> Result<crate::source_paint::Progress> {
if let crate::source_paint::Progress::Complete(draft) = &progress {
let (reads, names) = crate::presentation::split_reads(draft.reads.clone());
let mut state = self
.session
.lock()
.map_err(|_| anyhow::anyhow!("UI session poisoned"))?;
let desktops = state.host_desktops();
let reads = draft
.reads
.iter()
.filter(|read| !desktops.contains(&read.object()))
.cloned()
.collect();
let (reads, names) = crate::presentation::split_reads(reads);
state.paint_reads = reads;
state.paint_names = names;
state.paint_slices = draft.slices;
@@ -2893,8 +2909,8 @@ impl UiBridge {
let crate::source_layout::Draft {
mut frame,
runtime: mut layout,
cache,
reads,
mut cache,
mut reads,
} = draft;
let result: Result<crate::document::Frame> = (|| {
self.select_window(window)?;
@@ -2910,6 +2926,16 @@ impl UiBridge {
frame.tabs = tabs;
frame.window = window;
// Capture versions before lifecycle hooks can change a dependency.
let desktops = self
.session
.lock()
.map_err(|_| anyhow::anyhow!("UI session poisoned"))?
.host_desktops();
// Shared intrinsic functions capture the primary desktop even when
// invoked from another window. Desktop bookkeeping is private host
// state; Window, viewport input and business dependencies remain.
reads.retain(|read| !desktops.contains(&read.object()));
cache.exclude_host_desktops(&desktops);
let (reads, names) = crate::presentation::split_reads(reads);
frame.focus = match vm.get_attr(desktop, "focus") {
Ok(Value::Number(id)) => id.as_i64().and_then(|n| u64::try_from(n).ok()),