Reapply monitor placements after display topology changes
This commit is contained in:
parent
7ed0c1e92f
commit
6e7694e67c
|
|
@ -2245,7 +2245,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pdf-presenter"
|
||||
version = "0.1.73"
|
||||
version = "0.1.74"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.73"
|
||||
version = "0.1.74"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"
|
||||
|
|
|
|||
|
|
@ -578,9 +578,16 @@ impl App {
|
|||
s.draft_routes = s.routes.clone();
|
||||
}
|
||||
}
|
||||
if changed && let Some(host) = &mut self.host {
|
||||
host.presented.clear();
|
||||
for w in &self.windows {
|
||||
if changed {
|
||||
if let Some(host) = &mut self.host {
|
||||
host.presented.clear();
|
||||
}
|
||||
for w in &mut self.windows {
|
||||
// The OS may move a surviving window when another display is
|
||||
// removed. Its route ID/fullscreen flag can remain unchanged,
|
||||
// so discard placement cached for the old desktop topology.
|
||||
w.target = None;
|
||||
w.transition = None;
|
||||
if !self.handles.iter().any(|(m, _)| m.id == w.monitor) {
|
||||
w.window.set_visible(false);
|
||||
}
|
||||
|
|
@ -1600,7 +1607,7 @@ mod buffer_tests {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn three_native_windows_render_without_clicks_and_then_stop_repainting() {
|
||||
fn three_native_windows_render_without_clicks_and_reset_placement_on_topology_change() {
|
||||
if std::env::var_os("PDF_PRESENTER_GUI_TESTS").is_none() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1608,13 +1615,16 @@ mod buffer_tests {
|
|||
struct Harness {
|
||||
app: App,
|
||||
started: Instant,
|
||||
topology_checked: bool,
|
||||
}
|
||||
impl ApplicationHandler for Harness {
|
||||
fn resumed(&mut self, el: &ActiveEventLoop) {
|
||||
self.app.handles = monitors(el).0;
|
||||
let id = self.app.handles[0].0.id.clone();
|
||||
for index in 0..3 {
|
||||
let window =
|
||||
NativeWindow::create(el, Role::Presentation, format!("test-{index}"))
|
||||
.unwrap();
|
||||
let mut window =
|
||||
NativeWindow::create(el, Role::Presentation, id.clone()).unwrap();
|
||||
window.target = Some((id.clone(), false));
|
||||
let _ = window
|
||||
.window
|
||||
.request_inner_size(PhysicalSize::new(180, 120));
|
||||
|
|
@ -1634,6 +1644,19 @@ mod buffer_tests {
|
|||
for window in &mut self.app.windows {
|
||||
window.repaint_if_due(now);
|
||||
}
|
||||
if !self.topology_checked
|
||||
&& now.duration_since(self.started) >= Duration::from_millis(200)
|
||||
{
|
||||
// Simulate a previous desktop layout. Route IDs and fullscreen
|
||||
// are unchanged, but all three placements must be invalidated.
|
||||
self.app.handles[0].0.origin.0 += 1;
|
||||
self.app.refresh(el);
|
||||
for window in &self.app.windows {
|
||||
assert!(window.target.is_none());
|
||||
assert!(window.transition.is_none());
|
||||
}
|
||||
self.topology_checked = true;
|
||||
}
|
||||
if now.duration_since(self.started) >= Duration::from_secs(1) {
|
||||
el.exit();
|
||||
}
|
||||
|
|
@ -1643,6 +1666,7 @@ mod buffer_tests {
|
|||
let now = Instant::now();
|
||||
let mut harness = Harness {
|
||||
started: now,
|
||||
topology_checked: false,
|
||||
app: App {
|
||||
studio: None,
|
||||
host: None,
|
||||
|
|
@ -1672,6 +1696,7 @@ mod buffer_tests {
|
|||
.run_app(&mut harness)
|
||||
.unwrap();
|
||||
assert!(harness.app.error.is_none(), "{:?}", harness.app.error);
|
||||
assert!(harness.topology_checked);
|
||||
assert_eq!(harness.app.windows.len(), 3);
|
||||
for window in &harness.app.windows {
|
||||
assert!(window.frames > 0, "Every mirror must paint without a click");
|
||||
|
|
|
|||
|
|
@ -1453,3 +1453,47 @@ fn held_navigation_buttons_accelerate_and_release_without_an_extra_step() {
|
|||
assert!(native.navigation_hold.is_none());
|
||||
assert!(!s.blanked);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn third_monitor_routes_restore_after_repeated_disconnects_without_changing_visibility() {
|
||||
for third_is_presenter in [false, true] {
|
||||
for blanked in [false, true] {
|
||||
let mut s = studio();
|
||||
s.monitors.push(Monitor {
|
||||
id: "three".into(),
|
||||
name: "Third".into(),
|
||||
origin: (3840, 0),
|
||||
size: (1920, 1080),
|
||||
});
|
||||
if third_is_presenter {
|
||||
s.routes.presenter.push("three".into());
|
||||
} else {
|
||||
s.routes.presentation.push("three".into());
|
||||
}
|
||||
s.settings.routes = s.routes.clone();
|
||||
s.blanked = blanked;
|
||||
let saved = s.settings.routes.clone();
|
||||
let all = s.monitors.clone();
|
||||
for missing in [2, 1, 2] {
|
||||
let connected = all
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(index, _)| *index != missing)
|
||||
.map(|(_, monitor)| monitor.clone())
|
||||
.collect();
|
||||
s.set_monitors(connected, 0);
|
||||
assert!(!s.routes.presenter.contains(&all[missing].id));
|
||||
assert!(!s.routes.presentation.contains(&all[missing].id));
|
||||
assert_eq!(s.settings.routes, saved);
|
||||
assert_eq!(s.blanked, blanked);
|
||||
s.new_output = false;
|
||||
s.dirty_routes = false;
|
||||
s.set_monitors(all.clone(), 0);
|
||||
assert_eq!(s.routes, saved);
|
||||
assert!(s.new_output && s.dirty_routes);
|
||||
assert_eq!(s.blanked, blanked);
|
||||
assert!(!s.privacy_hold);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### 0.1.74
|
||||
|
||||
- Reapply all native window placements after monitor topology changes, even when
|
||||
assigned monitor IDs and fullscreen flags remain the same. This repairs stale
|
||||
positions after the OS relocates windows during unplug/replug cycles.
|
||||
- Cover repeated third/middle monitor disconnects with presenter and presentation
|
||||
mirrors, preserving saved roles and show/blank state; verify topology changes
|
||||
invalidate placement for three native windows. Physical reconnect testing remains
|
||||
open, including Windows/macOS. Linux workspace/native and 13 Python tests pass,
|
||||
along with formatting and warnings-denied Clippy/rustdoc; whole-application
|
||||
coverage is 84.56% (75% floor). The Linux release binary is rebuilt.
|
||||
|
||||
### 0.1.73
|
||||
|
||||
- Stop self-perpetuating native repaint requests that can starve other selected
|
||||
|
|
|
|||
|
|
@ -400,3 +400,23 @@ paints in one second. The fixed version passes alongside the full Linux workspac
|
|||
and native tests, 13 Python helper tests, formatting, and warnings-denied Clippy
|
||||
and rustdoc. Whole-application coverage is 84.57% against the 75% floor. The Linux
|
||||
release binary is rebuilt; no Windows/macOS builds or publication were performed.
|
||||
|
||||
|
||||
## 0.1.74 reconnect placement
|
||||
|
||||
Topology changes now invalidate each native window's placement target and pending
|
||||
transition. Reconciliation reapplies its selected monitor and fullscreen mode even
|
||||
when the route ID is unchanged: an OS relocation during disconnect must not become
|
||||
permanent merely because the old ID/fullscreen tuple still matches. Missing windows
|
||||
are hidden before reconciliation; saved route choices and output visibility remain
|
||||
unchanged. Existing X11 staged placement is reused.
|
||||
|
||||
Regression coverage includes repeated disconnect/reconnect of the third and middle
|
||||
monitors, with the third assigned to either role and with output shown or blanked.
|
||||
The native three-window test also simulates a topology change while retaining route
|
||||
IDs and verifies all cached placements are discarded. These checks do not establish
|
||||
physical hotplug acceptance or Windows/macOS compositor behavior.
|
||||
|
||||
Linux formatting, warnings-denied Clippy/rustdoc, workspace/native tests and 13
|
||||
Python helper tests pass. Whole-application coverage is 84.56% (75% floor), and
|
||||
the Linux release binary is rebuilt. Windows/macOS builds were not run.
|
||||
|
|
|
|||
Loading…
Reference in New Issue