Fix external monitor geometry conversion#206
Merged
Merged
Conversation
023588a to
2076102
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Greptile Summary
This PR fixes AX/CG rectangle conversion for multi-monitor setups by replacing a single desktop-union Y-flip with per-display geometry. A new
DisplayCoordinateConverterenum handles all coordinate math against injectedDisplayGeometrysnapshots, keeping it fully testable withoutNSScreen.DisplayCoordinateConverterandDisplayGeometrytotabby/Support/, correctly flipping CG rects within their owning display and handling Retina pixel-to-point scaling anchored at each display's own origin rather than the global origin.AXHelper.cocoaRectandvalidatedCocoaTextRectto use the new per-display converter withlegacyDesktopUnionFlipas a last-resort fallback, and refactorsOverlayController.targetScreenVisibleFrameto prefer caret-midpoint containment invisibleFramebefore the frame-intersection fallback.DisplayCoordinateConverterTestswith three pure-geometry tests covering above-primary, negative-X boundary-crossing, and Retina-origin display layouts.Confidence Score: 5/5
Safe to merge; the per-display Y-flip math is correct for primary, side-by-side, above-primary, and Retina configurations, and the legacy fallback is preserved for virtual/mirrored displays without an NSScreenNumber.
The coordinate arithmetic has been verified against all three test scenarios and the fallback paths (legacyDesktopUnionFlip, displays.isEmpty early-return) correctly mirror the pre-existing behavior. No new crash paths, data loss, or security concerns were introduced.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[AX/CG rect from Accessibility API] --> B{cocoaRect or validatedCocoaTextRect?} B -->|cocoaRect| C[displayGeometries] B -->|validatedCocoaTextRect| D[displayGeometries] C --> E{displays empty?} E -->|no| F[DisplayCoordinateConverter.appKitRect] E -->|yes| G[legacyDesktopUnionFlip] F -->|nil| G F -->|converted| H[Return AppKit rect] G --> H D --> I{displays empty?} I -->|yes| J[Return raw textRect no Y-flip] I -->|no| K[Candidate A: appKitRect ?? legacyDesktopUnionFlip] K --> L{anchor available?} L -->|no| M[Return Candidate A] L -->|yes| N{Candidate A midpoint inside expandedAnchor?} N -->|yes| M N -->|no| O[Candidate B: appKitRectsFromPixelRect] O --> P{Any Candidate B inside expandedAnchor?} P -->|yes| Q[Return first matching Candidate B] P -->|no| R[Return Candidate A best-effort]Reviews (2): Last reviewed commit: "Fix external monitor geometry conversion" | Re-trigger Greptile