diff --git a/Cargo.lock b/Cargo.lock index 7e83579..61fb213 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2212,7 +2212,7 @@ dependencies = [ [[package]] name = "pdf-presenter" -version = "0.1.27" +version = "0.1.28" dependencies = [ "bytemuck", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 1f7ada7..c13b615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"] resolver = "3" [workspace.package] -version = "0.1.27" +version = "0.1.28" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter" diff --git a/crates/pdf-presenter/src/native.rs b/crates/pdf-presenter/src/native.rs index db85405..23e48fe 100644 --- a/crates/pdf-presenter/src/native.rs +++ b/crates/pdf-presenter/src/native.rs @@ -470,7 +470,7 @@ impl App { } Ok(()) } - fn key(&mut self, role: Role, key: Key, consumed: bool, modifiers: bool) { + fn key(&mut self, role: Role, key: Key, consumed: bool, modifiers: egui::Modifiers) { if role == Role::Presentation { if matches!(key, Key::Named(NamedKey::Escape)) && let Some(host) = &self.host @@ -505,7 +505,7 @@ impl App { s.execute(Action::RevertRoutes); return; } - if modifiers || consumed { + if modifiers.ctrl || modifiers.alt || modifiers.command || consumed { return; } match key { @@ -540,6 +540,9 @@ impl App { s.execute(Action::Windowed); } } + Key::Named(NamedKey::Space) if role == Role::Presenter && modifiers.shift => { + s.execute(Action::Go(s.requested.saturating_sub(1))) + } Key::Named(NamedKey::ArrowRight | NamedKey::PageDown | NamedKey::Space) if role == Role::Presenter => { @@ -911,9 +914,7 @@ impl ApplicationHandler for App { role, event.logical_key, native.ctx.egui_wants_keyboard_input(), - native - .ctx - .input(|i| i.modifiers.ctrl || i.modifiers.alt || i.modifiers.command), + native.input.egui_input().modifiers, ); } WindowEvent::Resized(_) | WindowEvent::ScaleFactorChanged { .. } => { @@ -1130,6 +1131,67 @@ pub fn run_output() -> Result<(), Failure> { #[cfg(test)] mod buffer_tests { use super::*; + #[test] + fn space_navigation_respects_shift_focus_roles_and_blanking() { + let now = Instant::now(); + let mut studio = Studio::new(true, None); + studio.deck = Some(crate::document::DeckInfo { + path: "test.pdf".into(), + key: "test".into(), + title: "Test".into(), + names: vec!["1".into(), "2".into(), "3".into()], + notes: vec![], + warnings: vec![], + sha256: String::new(), + }); + studio.blanked = true; + let mut app = App { + studio: Some(studio), + host: None, + output: None, + lease: None, + windows: vec![], + handles: vec![], + next_poll: now, + next_clock: now, + next_monitors: now, + x11: false, + error: None, + smoke: false, + smoke_stage: 0, + started: now, + windowed: true, + override_presenter: None, + override_output: None, + }; + for (role, consumed, modifiers, expected) in [ + (Role::Presenter, false, egui::Modifiers::NONE, 1), + (Role::Presenter, false, egui::Modifiers::SHIFT, 0), + (Role::Presenter, false, egui::Modifiers::SHIFT, 0), + (Role::Presenter, false, egui::Modifiers::NONE, 1), + (Role::Presenter, true, egui::Modifiers::SHIFT, 1), + ( + Role::Presenter, + false, + egui::Modifiers::SHIFT | egui::Modifiers::CTRL, + 1, + ), + ( + Role::Presenter, + false, + egui::Modifiers::SHIFT | egui::Modifiers::ALT, + 1, + ), + (Role::Browser, false, egui::Modifiers::SHIFT, 1), + (Role::Presentation, false, egui::Modifiers::SHIFT, 1), + (Role::Presenter, false, egui::Modifiers::NONE, 2), + (Role::Presenter, false, egui::Modifiers::NONE, 2), + ] { + app.key(role, Key::Named(NamedKey::Space), consumed, modifiers); + assert_eq!(app.studio.as_ref().unwrap().requested, expected); + assert!(app.studio.as_ref().unwrap().blanked); + } + } fn frame(page: usize) -> Arc { Arc::new(Frame { info: crate::document::FrameInfo { diff --git a/docs/changelog.md b/docs/changelog.md index 74d33f2..c0e7202 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,14 @@ ## Unreleased +### 0.1.28 + +- Add Shift+Space to move back one slide from the presenter; Space still advances. + Read current input modifiers so Shift works even before the next repaint. + Preserve text-input focus, slide boundaries and manual blanking. Linux tests, + native X11 smoke, formatting, Clippy/rustdoc and Python checks pass; whole-app + coverage is 86.70%. Windows/macOS runtime checks were not run. + ### 0.1.27 - Remove Jenkins's Xvfb prerequisite and native-window test wrapper. Keep native diff --git a/docs/user-guide.md b/docs/user-guide.md index fecbf7b..cb41af3 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -73,7 +73,8 @@ Escape cancels a pending slide number/menu, closes the browser, or safely leaves fullscreen and blanks output. While the presenter is connected, closing a presentation window blanks it; close a presenter or choose Menu → Quit to end the application. -Arrow keys, Page Up/Down and Space navigate from the presenter. Type a 1-based slide +Arrow keys and Page Up/Down navigate from the presenter. Space moves forward; +Shift+Space moves back. Type a 1-based slide number then Enter to jump; Backspace edits and Escape cancels. Out-of-range numbers do not navigate. Output windows accept B/Escape for emergency blanking.