Skip to content

fix(overlay): map tooltips with the overlay's own DPI and live origin - #77

Open
DysektAI wants to merge 2 commits into
masterfrom
fix/overlay-dpi-offset
Open

DysektAI wants to merge 2 commits into
masterfrom
fix/overlay-dpi-offset

Conversation

@DysektAI

Copy link
Copy Markdown
Member

Why

Users report scan overlays "off by a bit". Scan positions are physical pixels; the overlay page divided them by SettingsVM.ScreenScale, which is the game display's DPI, a custom display-scale override, or the unsaved settings draft (UpdateDisplayPreview writes it live). WebView2's CSS pixels follow the overlay window's DPI. Whenever those differ (mixed-DPI monitors, custom scale, editing display settings) tooltips drift, more the further from the virtual-screen origin. VirtualScreenOffset was also computed once at startup, while the window is re-sized on every show, so monitor changes broke the origin.

What

  • VirtualScreenOffset becomes a live mapping: origin + DeviceScale, updated by the overlay on every tooltip show (GetDpiForWindow after SetWindowPos) and on DpiChanged; raises Changed only on real changes.
  • The overlay page scales by VirtualScreenOffset.DeviceScale and re-renders on Changed; it no longer depends on SettingsVM.
  • Shared VirtualScreenBounds replaces the two copies of the bounds loop.

Validation

  • VirtualScreenOffsetTests: bounds with monitors left/above the primary, update + single notification (dedupe mutation fails it), DPI-only change, invalid scale fallback, contract that the overlay no longer reads ScreenScale.
  • Debug and Release build; dotnet test 412/412; verify.ps1 -Mode Ui 2/2; CodeRabbit: no findings.

Not proven

  • ⚠️ No automated tooltip-position assertion against a real scan; needs a manual check on a single 100% monitor (unchanged), a 125/150% monitor, and a mixed-DPI pair.
  • Rotated-icon position mapping in RatEye is a separate fix.

https://claude.ai/code/session_01QFKiA2aswHyp8SnpraLxE2

Scan positions are physical pixels; the overlay page converted them to
CSS pixels with SettingsVM.ScreenScale, which is the game display's DPI,
a custom display-scale override, or even an unsaved settings draft. The
overlay's CSS pixels follow the overlay window's DPI instead, so on
mixed-DPI setups or with a custom scale, tooltips drifted away from the
item (growing with distance from the virtual-screen origin).
VirtualScreenOffset was also computed once at startup and went stale
when monitors changed, while the window itself was re-sized every show.

- The overlay records its virtual-screen origin and GetDpiForWindow scale
  every time it is sized for a tooltip, and on DpiChanged.
- The overlay page scales by that DPI and re-renders when it changes.

Claude-Session: https://claude.ai/code/session_01QFKiA2aswHyp8SnpraLxE2
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 68 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 63eb3b7a-c4b5-4024-9816-10166d69827e
📥 Commits

Reviewing files that changed from the base of the PR and between c15eda6 and 928ff26.

📒 Files selected for processing: 6
  • src/App/Pages/Overlay/Index.razor
  • src/App/View/BlazorOverlay.xaml.cs
  • src/App/View/BlazorUI.xaml.cs
  • src/App/View/OverlayNativeMethods.cs
  • src/App/VirtualScreenOffset.cs
  • tests/RatScanner.Tests/VirtualScreenOffsetTests.cs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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