Skip to content

Anchor show-taps overlay window to the host view#5

Open
takahirom wants to merge 2 commits into
saket:trunkfrom
takahirom:show-taps-overlay-anchor-fix
Open

Anchor show-taps overlay window to the host view#5
takahirom wants to merge 2 commits into
saket:trunkfrom
takahirom:show-taps-overlay-anchor-fix

Conversation

@takahirom

Copy link
Copy Markdown

Fixes #3.

Stacked on #4 and contains its commits (GitHub can't stack cross-fork PRs, so this PR's diff includes the reproducer from #4 plus the fix commit on top). Review just the last commit ("Anchor show-taps overlay window to the host view") for the actual change.

The fix

MatchParentSizePopup added the overlay window with only width/height set, leaving WindowManager.LayoutParams.gravity at its default (0). With gravity 0, WindowManager centers the window on screen, so an overlay smaller than the screen is drawn offset from the host view — and from the taps, which are drawn at the host's coordinates.

This anchors the overlay explicitly:

  • Set gravity = Gravity.TOP or Gravity.LEFT and initialize x/y from hostView.getLocationOnScreen(...).
  • Refresh x/y (as well as width/height) from the host's current location in the existing doOnEveryLayout { ... } block, since the host can move, not just resize.

LEFT is used deliberately instead of START: x/y are absolute screen coordinates, and START would be mirrored under RTL layout direction, reintroducing the offset on RTL locales.

Verification

The reproducer test added in #4 passes with this fix, and touchrobot-core:check + touchrobot-paparazzi:check (including the Paparazzi snapshot verification) are green — the fix does not change any existing screenshots.

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.

Show-taps overlay is misplaced (centered) when the host view doesn't fill the screen

1 participant