Skip to content

fix(ui): TranslateFromScreen resolves the surface offset for any surface root - #71

Merged
mstrobel merged 1 commit into
developfrom
fix/translate-from-screen-surface
Sep 7, 2026
Merged

mstrobel merged 1 commit into
developfrom
fix/translate-from-screen-surface

Conversation

@mstrobel

@mstrobel mstrobel commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • UIElement.TranslateFromScreen subtracted the surface offset only when the visual root was a Window or the Popup element. A popup's hosted child is its own surface root (the Popup stays in the owner's tree), so the root is Popup arm never fired for popup content.
  • Inside a popup placed away from the screen origin, MouseEventArgs.GetPosition(element) therefore came back offset by the popup's (Left, Top). Found via CursorialEdit's drag-to-size table picker (a drawn Control in a BarPopupButton dropdown): hover and clicks landed rows/columns away from the pointer whenever the dropdown opened below the ribbon rather than at the origin.
  • Fix: resolve the surface through WindowManager.SurfaceForElement(root), exactly as TranslateToScreen does, so the two are inverses for every surface kind.

Test plan

  • New WindowPopupTests.PlacedPopup_TranslateFromScreen_AndGetPosition_AreElementLocal: a popup placed below an offset target — element→screen→element round-trips, and a dispatched press reports element-local cells.
  • Cursorial.UI.Tests full run: 3962 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_013qbF5ru6uh5w7fqhP3yoPE

…ace root (popup content GetPosition)

UIElement.TranslateFromScreen only subtracted the surface offset when the visual root was a Window or the
Popup element itself. A popup's hosted child is its own surface root (the Popup element stays in the owner's
tree), so inside a popup placed away from the screen origin MouseEventArgs.GetPosition came back offset by
the popup's (Left, Top) — hover and clicks in a drawn control inside a BarPopupButton dropdown landed rows
and columns away from the pointer. Resolve the surface through WindowManager.SurfaceForElement, exactly as
TranslateToScreen already does, so the two are inverses for every surface kind.

Regression test: a popup placed below an offset target — element→screen→element round-trips and the
dispatched press reports element-local cells.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013qbF5ru6uh5w7fqhP3yoPE
@mstrobel
mstrobel merged commit bed7e68 into develop Sep 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant