Skip to content

fix(macos): hit-test click candidates in window points - #126

Merged
iFurySt merged 4 commits into
iFurySt:mainfrom
hyprcat:fix/hit-test-window-points
Oct 31, 2026
Merged

iFurySt merged 4 commits into
iFurySt:mainfrom
hyprcat:fix/hit-test-window-points

Conversation

@hyprcat

@hyprcat hyprcat commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem and fix

AX hit testing receives window-relative points from both click callers. Treating them as screenshot pixels applied screenshot scaling a second time, so Retina/capped screenshots could target another control; AX-only indexed clicks could incorrectly require a screenshot.

Convert these points directly with the window's screen origin. Screenshot-coordinate input still converts once at its entry point. Merged current main (a7fdec1) and retained the contributor's fix. Added opt-in hit-test diagnostics and a reproducible real AppKit/native MCP smoke.

Validation

  • Full Swift suite: 399 tests, 9 skipped, 0 failures.
  • Real locally signed release build, native MCP and AppKit AX receiver on a Retina display: 600×432-point window, 1200×864 and 300×216 screenshots. Indexed hit tests resolve the correct screen point without pressing the unrelated button; screenshot-coordinate auto clicks and explicit AXPress actually activate the receiver button.
  • AX-only indexed hit testing succeeds; screenshot-coordinate clicks without an image are refused. Foreground PID and physical pointer stay unchanged during actions.
  • Negative control reverting only the conversion fails the same smoke: expected (490,627), observed (305,498.5).
  • Documentation checks and git diff --check pass.

Reproduce: node scripts/tests/macos-hit-test-smoke.mjs <signed-ocu-executable> with existing Accessibility/Screen Recording permissions and runtime admission on an unlocked Retina desktop.

Scope

One physical Retina display was tested. General background mouse delivery to actionless custom views is not established by this test. The independent descendant-selection bug in #127 remains separate; this change fixes coordinate conversion only. Windows and Linux do not use this Swift AX path.

hitTestElement converted its point as a screenshot pixel, but both callers
(clickCandidates and the nearby hit-test fallback for element-index clicks)
pass window points. When the screenshot is not 1:1 with the window the AX hit
test probed the wrong spot: an auto click on a table row pressed the column
header above it, and element-index clicks after include_screenshot:false threw
the coordinate-input screenshot error. Use windowPointToGlobalPoint.

@iFurySt iFurySt left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

…review

# Conflicts:
#	docs/releases/feature-release-notes.md
@iFurySt
iFurySt merged commit 74d86db into iFurySt:main Oct 31, 2026
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.

2 participants