From 4566f5f55fe6728fee6571b22aa18d9eda451c9f Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 13 Oct 2026 01:58:43 +0200 Subject: [PATCH] Shape tools: the click-to-open-dialog tolerance is the same on HiDPI displays (#4205) (#4207) finish_gesture passed the device-pixel zoom (current_zoom) to shape_dialog::is_click, whose 3-point slop is in egui points, so at pixels_per_point 2 the tolerance halved and a slightly jittery click drew a tiny shape instead of opening Create Rectangle/Ellipse/... Pass point_zoom(), as the marquee already does. Regression test: a 2 pt jitter at ppp 2 and 100 % opens the dialog and adds no layer. Co-authored-by: Claude Opus 5.5 (1M context) --- crates/ui-egui/src/canvas.rs | 2 +- crates/ui-egui/src/shape_dialog_tests.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index ebbfc7a40a..911e428a69 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -5176,7 +5176,7 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) { Tool::FreeformPen => crate::vector_ui::freeform_finish(app, &d.points, d.lasso.as_ref().map_or(&[], |l| l.straight())), // Photoshop: a click without dragging opens Create Rectangle / Ellipse / … instead. t if crate::vector_ui::is_shape_tool(t) - && crate::shape_dialog::is_click(d.start, &d.points, app.current_zoom()) + && crate::shape_dialog::is_click(d.start, &d.points, app.point_zoom()) && crate::shape_dialog::open(app, t, d.start).is_some() => {} t if crate::vector_ui::is_shape_tool(t) => crate::vector_ui::finish_shape(app, t, d.start, [end[0], end[1]], d.live), Tool::PathSelection => crate::vector_ui::path_selection_finish(app, d.start, [end[0], end[1]]), diff --git a/crates/ui-egui/src/shape_dialog_tests.rs b/crates/ui-egui/src/shape_dialog_tests.rs index fde2cf78c7..a0b5c61596 100644 --- a/crates/ui-egui/src/shape_dialog_tests.rs +++ b/crates/ui-egui/src/shape_dialog_tests.rs @@ -141,6 +141,20 @@ fn click_slop_scales_with_zoom() { assert!(is_click([10.0, 10.0], &[], 0.0)); } +/// #4205: the click slop is in screen points, so on a 2x (HiDPI) display at 100 % a 2 pt jitter +/// (4 device px = 4 document px) is still a click that opens Create Rectangle, not a tiny shape. +#[test] +fn a_click_with_jitter_opens_the_dialog_on_hidpi() { + let mut app = app(); + app.ppp = 2.0; + let i = app.session.active_index().unwrap(); + app.ui.views[i].zoom = 1.0; + let before = layers(&app); + press(&mut app, Tool::Rectangle, [20.0, 30.0], [24.0, 30.0]); + only_dialog(&app); + assert_eq!(layers(&app), before, "a jittery click draws nothing"); +} + #[test] fn cancel_draws_nothing_and_ok_remembers_the_size() { let mut app = app();