Skip to content

Eliminate portrait eighth-snap gaps on displays whose height is not divisible by 4 - #1812

Open
YuriNachos wants to merge 1 commit into
rxhanson:mainfrom
YuriNachos:YuriNachos/w4-rectangle-eighth
Open

Eliminate portrait eighth-snap gaps on displays whose height is not divisible by 4#1812
YuriNachos wants to merge 1 commit into
rxhanson:mainfrom
YuriNachos:YuriNachos/w4-rectangle-eighth

Conversation

@YuriNachos

Copy link
Copy Markdown

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). When height % 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 consistent floor(height/4) basis and abut exactly against each other and against the top-anchored row 1.
  • RectangleTests/RectangleTests.swift — a PortraitEighthAbutmentTests class: for a non-divisible height (1002) it asserts the row origins form the maxY - cellH*k grid and the two middle seams abut with no gap/overlap; for a divisible height (1000) it asserts all three seams abut (control).

Behavior notes

  • For heights divisible by 4 the math is numerically identical to before (floor(h/4)*3 == h*0.75, floor(h/4)*2 == h/2), so the already-seamless case is unchanged.
  • For non-divisible heights the floor remainder is no longer scattered across the two middle seams; it collects as a single 1-2px step at the bottom edge (between the third row, anchored from maxY, and the bottom row, anchored at minY). 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 on main (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.

…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.
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