Files
deckcraft/crates/ui-egui/src/presenter_tests.rs
T
Michael Müllerandaiongg 73de9900a7 Show: Presenter View only with a second display (#1156)
* Show: Presenter View only with a second display

With one display the presenter window opened on the same screen as the show. Under Hyprland's
focus-follows-mouse, whichever window the pointer was over took full screen, and the hidden one
stalled every frame: the show lagged, dropped key presses or froze.

One display now shows only the slides, as in PowerPoint. The host counts displays through winit's
monitor list when a show starts; hosts that can't tell keep Presenter View.

* Show: count displays by MonitorHandle

Wayland lists one output twice under the same wl_output id, so comparing handles counts it once, and two separate displays with the same name and geometry still count as two.

* Show: docs for Presenter View with a second display

slideshow-parity and hardware-parity note that on Linux one display shows only the slides, with status lines and revision history; ROADMAP progress log. display_count collects into a BTreeSet (MonitorHandle's Ord matches its Eq).

* Show: docs state the one-display rule exactly

Presenter View stays off when winit lists exactly one display; if it lists none, the setting is kept. The host callback covers Unix other than macOS, so the docs say Linux and the BSDs.

* Apply review fixes

- docs/slideshow-parity.md

---------

Co-authored-by: aiongg <67543387+aiongg@users.noreply.github.com>
2026-11-05 12:51:16 +01:00

36 lines
1.6 KiB
Rust

//! JJ3: `show.presenter` answers the setting and where presenter view appears.
#![allow(clippy::unwrap_used, clippy::expect_used)]
use serde_json::json;
use crate::{Services, SlideApp};
use deckcraft_engine::Session;
#[test]
fn show_presenter_answers_on_and_window() {
let mut app = SlideApp::new(Session::with_new(), Services::default());
let v = app.run("show.presenter", json!({"on": true})).unwrap();
assert_eq!(v, json!({"on": true, "window": true}));
let v = app.run("show.presenter", json!({})).unwrap();
assert_eq!(v["on"], false, "no `on` toggles: {v}");
let doc = crate::UI_COMMANDS.iter().find(|c| c.0 == "show.presenter").unwrap().3;
assert!(doc.contains("separate window"), "{doc}");
}
#[test]
fn presenter_view_needs_a_second_display() {
// One display: the presenter window covered the show (or the show covered it) and the
// hidden window stalled every frame.
let presenter = |displays: Option<usize>, setting: bool| {
let services = Services { displays: Some(Box::new(move || displays)), ..Default::default() };
let mut app = SlideApp::new(Session::with_new(), services);
app.ui.presenter_view = setting;
app.start_show(0, false);
app.show.as_ref().map(|s| s.presenter)
};
assert_eq!(presenter(Some(1), true), Some(false));
assert_eq!(presenter(Some(2), true), Some(true));
assert_eq!(presenter(None, true), Some(true), "a host that can't count displays keeps Presenter View");
assert_eq!(presenter(Some(2), false), Some(false), "the setting still turns it off");
}