ui: sync viewport input touchpad speed on secondary viewports

This commit is contained in:
batistalucasv committed 2026-11-11 13:57:51 -03:00
1 parent 51901610fc
commit 278aae7235
3 files changed
+24 -4

No files matched your search

+1
View File
@@ -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
+13 -4
View File
@@ -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)
+10
View File
@@ -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));
}