Skip to content

Commit 2fd0948

Browse files
Owen McGirrOwen McGirr
authored andcommitted
Fix inverted vertical scrolling in the scanning menu
- Match menu Up and Down requests to the shared desktop scroll convention. - Verify all four directions through menu selection and fake input, including repeat execution and interval reset. - Preserve horizontal scrolling, shared adapters and Remote pointer behaviour. 🤖 Auto-generated
1 parent ec3cd5e commit 2fd0948

2 files changed

Lines changed: 80 additions & 4 deletions

File tree

src-tauri/src/point_workflow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ impl Workflow {
182182
Item::Up | Item::Down | Item::Left | Item::Right => {
183183
self.menu.restart_interval();
184184
let (dx, dy) = match item {
185-
Item::Up => (0, -3),
186-
Item::Down => (0, 3),
185+
Item::Up => (0, 3),
186+
Item::Down => (0, -3),
187187
Item::Left => (-3, 0),
188188
_ => (3, 0),
189189
};
@@ -738,15 +738,15 @@ mod tests {
738738
Some(Request::Scroll {
739739
point: (-1000, 20),
740740
dx: 0,
741-
dy: 3
741+
dy: -3
742742
})
743743
);
744744
assert_eq!(
745745
s.action(Action::Select),
746746
Some(Request::Scroll {
747747
point: (-1000, 20),
748748
dx: 0,
749-
dy: 3
749+
dy: -3
750750
})
751751
);
752752
s.action(Action::Next);

src-tauri/src/scan_executor.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,82 @@ mod tests {
266266
}
267267
}
268268
#[test]
269+
fn scanning_menu_scrolls_all_four_directions_and_repeats_without_leaving_menu() {
270+
use crate::point_scan::Config;
271+
use crate::point_workflow::{Phase, Workflow, WorkflowPhase};
272+
use crate::scanning::{Action, Rect, Session, Technique};
273+
274+
for automatic in [false, true] {
275+
for (row, column, dx, dy) in [(0, 0, 0, 3), (0, 1, 0, -3), (1, 0, -3, 0), (1, 1, 3, 0)]
276+
{
277+
let workflow = Workflow::new(
278+
Config {
279+
block_interval_ms: 250,
280+
..Config::default()
281+
}
282+
.point(),
283+
Rect {
284+
x: -500.0,
285+
y: 50.0,
286+
width: 1000.0,
287+
height: 800.0,
288+
},
289+
1.0,
290+
)
291+
.unwrap();
292+
let mut session = Session::new(workflow, automatic);
293+
for action in [
294+
Action::Select,
295+
Action::Select,
296+
Action::Select,
297+
Action::Next,
298+
Action::Select,
299+
Action::Select,
300+
] {
301+
assert_eq!(session.action(action), None);
302+
}
303+
for _ in 0..row {
304+
assert_eq!(session.action(Action::Next), None);
305+
}
306+
assert_eq!(session.action(Action::Select), None);
307+
for _ in 0..column {
308+
assert_eq!(session.action(Action::Next), None);
309+
}
310+
let mut input = DesktopInput::new(Fake::default());
311+
for _ in 0..2 {
312+
let before = session.frame().tiles;
313+
session.tick(100, false);
314+
let request = session.action(Action::Select).unwrap();
315+
assert_eq!(
316+
request,
317+
Request::Scroll {
318+
point: (-500, 50),
319+
dx,
320+
dy
321+
}
322+
);
323+
execute(&mut input, request, true).unwrap();
324+
assert_eq!(
325+
session.technique.phase(),
326+
Phase::Workflow(WorkflowPhase::Menu)
327+
);
328+
session.tick(100, false);
329+
assert_eq!(session.frame().tiles, before);
330+
assert_eq!(session.take_selection(), None);
331+
}
332+
assert_eq!(
333+
input.injector.events,
334+
vec![
335+
"move -500 50".to_string(),
336+
format!("scroll {dx} {dy}"),
337+
"move -500 50".to_string(),
338+
format!("scroll {dx} {dy}"),
339+
]
340+
);
341+
}
342+
}
343+
}
344+
#[test]
269345
fn resetting_an_executing_drag_releases_input_and_retains_failed_cleanup_for_retry() {
270346
let mut input = DesktopInput::new(Fake::default());
271347
execute(&mut input, Request::DragStart((100, 200)), true).unwrap();

0 commit comments

Comments
 (0)