Skip to content

lua: return absolute coordinates from PCSX.Helpers.UI.imageCoordinates - #2472

Merged
rixnobis merged 1 commit into
pcsx-redux:mainfrom
rixnobis:image-coords-absolute
Oct 23, 2026
Merged

rixnobis merged 1 commit into
pcsx-redux:mainfrom
rixnobis:image-coords-absolute

Conversation

@rixnobis

Copy link
Copy Markdown
Contributor

tvg.getViewportScene paints take ImGui coordinates, which are absolute with multi-viewports on. The renderer translates each viewport by minus its own position. imageCoordinates subtracted the viewport position as well, so every point it returned was shifted by it. It now returns GetCursorScreenPos() plus the scaled offset, which also stops ignoring the window's scroll (GetCursorPos adds it back).

Measured under Xvfb with a window placed at (300, 200): with -viewports the main viewport sat at (0, 112), the old helper returned (308, 118) and the absolute cursor was (308, 230). With -no-viewports both were (308, 230).

Viewport scenes take ImGui coordinates, which are absolute when
multi-viewports are enabled, and the renderer already offsets each
viewport. Subtracting the viewport position here shifted every point by
it. GetCursorScreenPos is the absolute cursor position, and also
accounts for the window's scroll.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 4b9a4f9 and 813d934.

📒 Files selected for processing: 1
  • src/gui/extra.lua

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

imageCoordinates now calculates image-scaled offsets from imgui.GetCursorScreenPos(). It no longer adjusts coordinates using window or viewport positions.

Changes: Image coordinate origin

Layer / File(s) Summary
Use cursor screen position as origin
src/gui/extra.lua
imageCoordinates uses the cursor screen position as its origin and removes window and viewport position adjustments.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested labels: size/S

Suggested reviewers: nicolasnoble

Merge Risk: ⚪ Minimal · up to 813d9

The coordinate-origin update matches the stated absolute-coordinate contract and is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: returning absolute coordinates from PCSX.Helpers.UI.imageCoordinates.
Description check Passed The description directly explains the coordinate bug, the multi-viewport behavior, the implementation change, and the measured results.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@rixnobis
rixnobis merged commit ffd805e into pcsx-redux:main Oct 23, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant