diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 17d57fd01c..e31411c4b2 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -354,6 +354,7 @@ impl WordApp { if !native { self.window_input(ctx); } + self.sync_viewport_input(ctx); self.send_control_input(ctx); // Screenshot deadlines, geometry and completions belong to `logic`; issuing the one // callback command belongs to `ui` (`flush_shot_and_synthetic`). A queued/settling capture diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 9b83c996c3..36b38008a4 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -766,10 +766,10 @@ impl WordApp { } } - /// The control channel's next input, for the active window when it has a viewport of its own: - /// handed to [`ViewportInput`], which gives it to that viewport's next pass. - pub(crate) fn send_control_input(&mut self, ctx: &egui::Context) { - if self.synthetic.is_empty() || self.control_input_is_roots(ctx) { + /// Ensures [`ViewportInput`] is registered and keeps its touchpad scroll speed in sync with + /// user settings for secondary viewports (#6146). + pub(crate) fn sync_viewport_input(&mut self, ctx: &egui::Context) { + if !self.windows.native { return; } if !self.windows.input_plugin { @@ -780,6 +780,15 @@ impl WordApp { ctx.with_plugin(|p: &mut ViewportInput| { p.touchpad_speed = speed; }); + } + + /// The control channel's next input, for the active window when it has a viewport of its own: + /// handed to [`ViewportInput`], which gives it to that viewport's next pass. + pub(crate) fn send_control_input(&mut self, ctx: &egui::Context) { + if self.synthetic.is_empty() || self.control_input_is_roots(ctx) { + return; + } + self.sync_viewport_input(ctx); self.settle_windows(); let target = self.active_viewport(); // Input queued for a window that has closed since (or moved into the root viewport) diff --git a/crates/ui-egui/src/windows/tests.rs b/crates/ui-egui/src/windows/tests.rs index 444d353606..11436fa42f 100644 --- a/crates/ui-egui/src/windows/tests.rs +++ b/crates/ui-egui/src/windows/tests.rs @@ -777,3 +777,13 @@ fn newly_opened_window_does_not_exceed_screen_width() { std::fs::remove_dir_all(doc1.parent().unwrap()).ok(); std::fs::remove_dir_all(doc2.parent().unwrap()).ok(); } + +#[test] +fn secondary_viewport_syncs_touchpad_scroll_speed_without_control_input() { + let ctx = backend(); + let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default()); + a.ui.touchpad_scroll_speed = crate::scroll::ScrollSpeed::Fast; + frame(&ctx, &mut a); + let speed = ctx.with_plugin(|p: &mut super::ViewportInput| p.touchpad_speed); + assert_eq!(speed, Some(crate::scroll::ScrollSpeed::Fast)); +}