Eliminate portrait eighth-snap gaps on displays whose height is not divisible by 4 - #1812
Open
YuriNachos wants to merge 1 commit into
Open
Eliminate portrait eighth-snap gaps on displays whose height is not divisible by 4#1812YuriNachos wants to merge 1 commit into
YuriNachos wants to merge 1 commit into
Conversation
…ivisible by 4 The four portrait eighth calculations derived their row origins from raw screen fractions (height * 0.75, height / 2.0) while their row height was floor(height / 4). When the visible-frame height is not divisible by 4 the raw-fraction boundaries do not land on the same pixels the adjacent cells' edges do, leaving 1-2px gaps (and occasional overlaps) between rows. Express each row origin as a cell-height multiple (rect.height * 2, rect.height * 3) so all four rows share one consistent floor(height/4) basis and abut exactly. Exact-divisible heights are unchanged.
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
Portrait-mode eighth snapping abuts cleanly: the middle row seams that previously left 1-2px gaps on displays whose height is not divisible by 4 now tile exactly. The unavoidable
floor(height/4)remainder collects at the bottom edge instead of being split across the middle seams.Root cause
The four portrait eighth calculations set each row's height to
floor(visibleFrame.height / 4)but derived two row origins from raw screen fractions (height * 0.75,height / 2.0). Whenheight % 4 != 0, the raw-fraction boundaries did not land on the floored cell edges, so the middle seams (rows 1-2 and 2-3) left 1-2px gaps.Changes
Rectangle/WindowCalculation/{TopCenterRightEighth,TopRightEighth,BottomLeftEighth,BottomCenterLeftEighth}Calculation.swift— express each of those two row origins as a cell-height multiple (rect.height * 2,rect.height * 3) so the top three rows share one consistentfloor(height/4)basis and abut exactly against each other and against the top-anchored row 1.RectangleTests/RectangleTests.swift— aPortraitEighthAbutmentTestsclass: for a non-divisible height (1002) it asserts the row origins form themaxY - cellH*kgrid and the two middle seams abut with no gap/overlap; for a divisible height (1000) it asserts all three seams abut (control).Behavior notes
floor(h/4)*3 == h*0.75,floor(h/4)*2 == h/2), so the already-seamless case is unchanged.maxY, and the bottom row, anchored atminY). This matches Rectangle's existing top/bottom anchoring convention; the test documents it explicitly. (A fully-seamless tile would require the bottom row to absorb the remainder with a non-uniform height, which is a separate design choice.)Testing
xcodebuild test -project Rectangle.xcodeproj -scheme Rectangle -destination 'platform=macOS'— 208 tests, 21 failures (0 unexpected). The 21 are the pre-existing red baseline onmain(cooperative-resize / corner-calculation suites, issues #1804–#1806); this change adds zero new failures and the new abutment tests pass.AI assistance
This change was developed with AI assistance (Claude Code); every changed line was reviewed and understood by the contributor.