From 60142de6eea2119feaff50dee2d332a366fa211b Mon Sep 17 00:00:00 2001 From: astar76 Date: Wed, 25 Nov 2026 00:28:42 -0600 Subject: [PATCH] S003: shots press and hover at 60 Hz Co-Authored-By: Claude Opus 5.5 --- crates/app/tests/shots.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/app/tests/shots.rs b/crates/app/tests/shots.rs index 4a8decf..54ab6f2 100644 --- a/crates/app/tests/shots.rs +++ b/crates/app/tests/shots.rs @@ -35,7 +35,7 @@ fn sources() -> Sources { fn harness(scene: Scene, appearance: Appearance, size: (f32, f32)) -> Harness<'static> { let mut app = None; - Harness::builder().with_size(vec2(size.0, size.1)).wgpu().build_ui(move |ui| { + Harness::builder().with_size(vec2(size.0, size.1)).with_step_dt(1.0 / 60.0).wgpu().build_ui(move |ui| { if app.is_none() { // Fonts count from the next frame. app = Some(App::new(ui.ctx(), settings(appearance), sources())); @@ -59,17 +59,17 @@ fn shots() { for (mode, appearance) in [("light", Appearance::Light), ("dark", Appearance::Dark)] { for size in sizes.split(',') { let mut h = harness(*scene, appearance, pair(size, 'x').expect("SIZES=WxH,WxH")); + // The pointer meets what the last frame drew. + h.run_steps(2); if let Some((x, y)) = hover { - let at = pos2(x, y); - h.input_mut().events.push(Event::PointerMoved(at)); - h.step(); - if std::env::var_os("PRESS").is_some() { - let press = Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }; - h.input_mut().events.push(press); - } + h.input_mut().events.push(Event::PointerMoved(pos2(x, y))); } - for _ in 0..60 { - h.step(); + h.run_steps(60); + if let Some((x, y)) = hover.filter(|_| std::env::var_os("PRESS").is_some()) { + let pos = pos2(x, y); + h.input_mut().events.push(Event::PointerButton { pos, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); + // egui gives up on a click held for 0.8 s. + h.run_steps(30); } if let Some(dir) = &out { h.render().expect("render").save(format!("{dir}/{}-{mode}-{size}.png", scene.0)).unwrap();