From dd80e7099a270fbbeea60871d5b3013368253ad5 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 27 Nov 2026 02:24:49 +0000 Subject: [PATCH] Canvas: press-state reads that a pointer move leaves alone (FW-365 F4) The vector tools' drain after every canvas run read `pointer::frame` only for the buttons held and the release, and the type transform box read it for the modifiers and the press. Both noted the pointer, so any pointer move ran the document area. They read `pointer::press_state` and `pointer::mods`, which only a press, a release or a modifier change moves. The pointer-over-panel trial stays held back: two craft-ui-canvas reads (the tool host, the middle-button autoscroll) still note the pointer on every canvas run. --- crates/ui-egui/src/canvas/canvas_settle_trials.rs | 6 ++++-- crates/ui-egui/src/modifier_keys.rs | 2 +- crates/ui-egui/src/tools/type_tool/canvas_tests.rs | 2 +- crates/ui-egui/src/tools/type_transform.rs | 9 +++++---- crates/ui-egui/src/tools/vector_ui/host.rs | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/canvas/canvas_settle_trials.rs b/crates/ui-egui/src/canvas/canvas_settle_trials.rs index b39cb52c3c..b211e89862 100644 --- a/crates/ui-egui/src/canvas/canvas_settle_trials.rs +++ b/crates/ui-egui/src/canvas/canvas_settle_trials.rs @@ -69,8 +69,10 @@ fn a_pointer_over_a_panel_replays_the_document_area() { for step in 1..=3 { h.event(Event::PointerMoved(beside + vec2(0.0, step as f32))); h.run_steps(1); - // Held back: a pointer move over the docked panels still runs the document area (FW-365 F4 report, finding 3: - // cause open). Turn these on with its fix. + // Held back: a pointer move over the docked panels still runs the document area. Two reads in the canvas + // note the pointer on every run: craft-ui-canvas's `ToolHost::run` (`pointer::frame`, for the tools' hover + // position) and `Canvas::autoscroll` (`pointer::frame`, for a press or the pointer leaving during a middle-button + // run). Turn these on once neither notes the pointer while it is away from the canvas. // assert_eq!(area(&h).0, 0, "hover step {step}: the document area replays"); // assert_eq!(part_runs(&h), [], "hover step {step}: no canvas part runs"); let _ = (area(&h), part_runs(&h)); diff --git a/crates/ui-egui/src/modifier_keys.rs b/crates/ui-egui/src/modifier_keys.rs index ccc892373f..64d5e599c5 100644 --- a/crates/ui-egui/src/modifier_keys.rs +++ b/crates/ui-egui/src/modifier_keys.rs @@ -1,5 +1,5 @@ //! The Modifier Keys panel: latching Shift, ⌘ and ⌥ for touch and pen users. Code that needs the held modifiers reads -//! `craft::ui::runtime::pointer::frame(ctx).mods`, which includes the latched keys. +//! `craft::ui::runtime::pointer::mods(ctx)`, which includes the latched keys. use craft::ui::contract::Bind; use craft::ui::patterns::panels::ModifierKeysPanel; diff --git a/crates/ui-egui/src/tools/type_tool/canvas_tests.rs b/crates/ui-egui/src/tools/type_tool/canvas_tests.rs index 0cd9005cf7..793cba3e7c 100644 --- a/crates/ui-egui/src/tools/type_tool/canvas_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/canvas_tests.rs @@ -921,7 +921,7 @@ fn command_mods() -> Mods { /// The modifiers held in the harness's last pass: the real keys plus the shell's latch (tp.T15). fn held(h: &Harness<'static, Box>) -> Mods { - craft::ui::runtime::pointer::frame(&h.ctx).mods + craft::ui::runtime::pointer::mods(&h.ctx) } fn hold(h: &mut Harness<'static, Box>, mods: Modifiers) { diff --git a/crates/ui-egui/src/tools/type_transform.rs b/crates/ui-egui/src/tools/type_transform.rs index f19df9e6c5..a7d30ab029 100644 --- a/crates/ui-egui/src/tools/type_transform.rs +++ b/crates/ui-egui/src/tools/type_transform.rs @@ -289,8 +289,9 @@ pub(crate) fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, canvas: egui::Rec return; } let ctx = ui.ctx().clone(); - let pointer = craft::ui::runtime::pointer::frame(&ctx); - if whole_box(app, pointer.mods) != drawn { + let mods = craft::ui::runtime::pointer::mods(&ctx); + let press = craft::ui::runtime::pointer::press_state(&ctx).press; + if whole_box(app, mods) != drawn { return; } let Some(frame) = frame(app) else { return }; @@ -307,11 +308,11 @@ pub(crate) fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, canvas: egui::Rec let out = TransformOverlay::new(Label::from(&*tl!("Type transform")), session, &settings) .reach(reach) .rotate_zone(RotateZone::border(ROTATE_REACH_PT)) - .mods(Some(pointer.mods)) + .mods(Some(mods)) .id_salt("type transform") .show_at(ui, canvas); // The press that went down on the box in this pass, or the box's first edit, starts the capture. - let pressed = out.held.is_some() && pointer.press.is_some(); + let pressed = out.held.is_some() && press.is_some(); if app.ui.type_transform.is_none() && !pressed && out.edits.is_empty() && out.apply.is_none() && !out.discard { return; } diff --git a/crates/ui-egui/src/tools/vector_ui/host.rs b/crates/ui-egui/src/tools/vector_ui/host.rs index 978485da1b..768115a2b8 100644 --- a/crates/ui-egui/src/tools/vector_ui/host.rs +++ b/crates/ui-egui/src/tools/vector_ui/host.rs @@ -146,9 +146,9 @@ pub(crate) fn drain(app: &mut PhotocraftApp, state: &mut VectorTools, _response: apply_pen(app, events); // A live shape layer takes the draft's anchors once a press is over (a release, or a key that changed the draft): // a drag's updates make no History steps of their own (#12909). - let pointer = craft::ui::runtime::pointer::frame(app.ctx()); + let presses = craft::ui::runtime::pointer::press_state(app.ctx()); let changed = app.ui.pen.as_ref().map(|p| &p.draft) != before.as_ref(); - if pointer.buttons.is_empty() && (changed || pointer.release.is_some()) { + if presses.buttons.is_empty() && (changed || presses.release.is_some()) { pen::sync_live_layer_from_draft(app); pen::sync_live_path_from_draft(app); }