Repository navigation
Floor the center third calculations to whole pixels - #1961
Open
AkiyamaKunka wants to merge 1 commit into
Open
AkiyamaKunka wants to merge 1 commit into
AkiyamaKunka wants to merge 1 commit into
Conversation
CenterThirdCalculation, CenterTwoThirdsCalculation and MiddleVerticalThirdCalculation floored the window origin but computed the size with a raw / 3.0, so on screens whose width or height isn't a multiple of 3 they placed windows on fractional pixels. A center third on a 1000pt-wide frame was 333.33pt wide, 0.67pt short of meeting the last third (which floors to 333). Every sibling calculation floors its size, so these three were the exception. Floor the sizes to match. The single center third now fills the remainder between the first and last thirds (width - 2 * floor(width / 3)) so the thirds tile with whole-pixel, gap-free geometry, and the center two-thirds is 2 * floor(width / 3) centered with an integer margin. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Three window calculations floor the window's origin but compute its size with a raw
/ 3.0:So on any screen whose width or height isn't a multiple of 3, they place windows on fractional pixels. On a 1000pt-wide frame the center third comes out
333.33ptwide — a non-integer window frame, and0.67ptshort of meeting the last third, which floors to333. Every other calculation (first/last thirds, quarters, sixths, ninths, …) floors its size, so these three are the exception:CenterThirdCalculation— width / heightCenterTwoThirdsCalculation— origin and sizeMiddleVerticalThirdCalculation— heightThe fix
Floor the sizes like the sibling calculations. The single center third now takes the remainder between the first and last thirds (
width - 2 * floor(width / 3)), so the three thirds tile the screen with whole-pixel, gap-free geometry; the center two-thirds becomes2 * floor(width / 3)centered with an integer margin.Example on a 1000×800 frame:
(333, 0, 333.33, 800)(333, 0, 334, 800)(166.5, 0, 666.67, 800)(167, 0, 666, 800)y 266, h 266.67y 266, h 268Tests
Added
CenterThirdsRectTests: whole-pixel geometry, the center third tiles contiguously with the first and last thirds, and the centered actions have equal margins on both sides. They fail onmainand pass with the fix. The full test suite passes (729 tests).