Skip to content

[CTX-1374] fix(rich): keep fill cover inside the image on HiDPI - #2283

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1374/fix-background-fill-dpi
Oct 19, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1374/fix-background-fill-dpi

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2278 (0.0.24 runtime matrix finding 4). The matrix run reported that
window.background_fit = "fill" letterboxed with smeared edge bands while
fit covered the window, i.e. the modes looked swapped.

They are not swapped. fit (contain) was already correct. fill (cover)
double-counted the window DPI factor: fit_plan scored the cover ratio against
the DPI-scaled native_w/native_h and then derived the source window as
dest / factor, which is dpix too large. The window ran past the image, and
rasterize_background's clamp(0, iw-1) turned the overshoot into the smear
bands, shrinking the visible image to 1/dpi of the width.

On the reporting host (dpi = 1.6, surface 2506x1496, wallpaper
3840x2160) the plan was src = [-974.5, 0, 5789.0, 3456.0]; the documented
cover is src = [110.86, 0, 3618.29, 2160.0]. fit only looked covered
because the window aspect (1.675) is close to the wallpaper aspect (1.778),
leaving a 43 px letterbox.

Change

crates/bitty-rich/src/background.rs — cover is scale-invariant, so the ratio
uses the raw image size. center/tile keep their intended DPI scaling.

Tests

  • fit_plan_fill_covers_within_image_bounds_at_any_dpi: cover stays inside
    the image, crops evenly, and is scale-invariant across dpi 1.0-3.0.
  • fit_plan_fit_is_contain_at_any_dpi: contain letterboxes the full image at
    every dpi.
  • fit_plan_fill_and_fit_are_not_interchangeable: mutation guard against an
    arm swap.
  • rasterize_fill_at_hidpi_does_not_clamp_edge_pixels: exact 2x upscale, no
    clamp smear.
  • window_fill_cover_stays_inside_the_image_at_hidpi (bitty-runtime):
    headless present path at apply_dpi_scale(1.6, 2506x1496); probes green/red/
    blue thirds - fails on the pre-fix code (36 % probe reads the green smear
    band instead of red).

Mutation evidence: restoring the DPI double-count fails 4 tests; swapping the
fill/fit arms fails 5.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo nextest run -p bitty-rich -p bitty-runtime --locked
  • cargo check --target x86_64-pc-windows-gnu --workspace --all-targets

Evidence (gitignored): recording/background-fit-geometry/ - product
screenshots, headless before/after renders, smear-run and coverage numbers.

Priority: P2 | Area: render | Labels: bug,P2,area:render | Milestone: 0.0.24 | RFC: OQ-042 | Task: CTX-1374

Closes #2278

The Fill arm of fit_plan scored the cover ratio against the DPI-scaled
native size and then derived the source window as dest / factor, so the
window came out dpi times too large. It ran past the image and the
rasterizer's clamp(0, iw-1) turned the overshoot into clamped smear bands,
shrinking the visible image to 1/dpi of the width. Cover is scale
invariant, so score it against the raw image size; center/tile keep their
DPI scaling.

Adds DPI-pinned unit tests (cover/contain geometry, no clamp smear, arm
swap guard) and a headless runtime pixel-coverage test at
apply_dpi_scale(1.6, 2506x1496).
@Xuepoo Xuepoo added this to the 0.0.24 milestone Oct 19, 2026
@Xuepoo Xuepoo added bug Something isn't working area:render Area: rendering P2 Priority: medium labels Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 652539b2-641e-49c5-9586-8732a78f4d1b
📥 Commits

Reviewing files that changed from the base of the PR and between a888b51 and fe80b68.

📒 Files selected for processing: 2
  • crates/bitty-rich/src/background.rs
  • crates/bitty-runtime/tests/background_images_present.rs
  • 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.

@Xuepoo
Xuepoo merged commit 97b9588 into main Oct 19, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the ctx-1374/fix-background-fill-dpi branch October 19, 2026 18:53
Xuepoo added a commit that referenced this pull request Oct 20, 2026
Cover the full `v0.0.23..main` range instead of the earlier partial passes:
all 71 merged commits are grouped under Added, Changed, Fixed, Security, and
Documentation, with PR numbers and the affected CTX tasks.

Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line
paste duplication and ghost fixed by the cursor clamp across wide spacers
(#2272), combining marks paint so decomposed `é` matches precomposed (#2279),
kitty font query and `bitty +show-font` (#2277), bounded native clipboard
acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the
`bitty.history` Lua surface (#2268), the production ComponentBroker plus
activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI
fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor
reservation (#2289).

Partials are marked honestly: #2254's request surface is still pending, the
#2213 disposition stays open, #2286 is feature-gated and unwired, the macOS
clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not
claimed because PR #2292 is unmerged. The heading reads `unreleased` because
the release is on hold; the tag date is set at tag time.

Docs-only: no code, scripts, workflows, or pins touched.
Xuepoo added a commit that referenced this pull request Oct 20, 2026
Cover the full `v0.0.23..main` range instead of the earlier partial passes:
all 71 merged commits are grouped under Added, Changed, Fixed, Security, and
Documentation, with PR numbers and the affected CTX tasks.

Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line
paste duplication and ghost fixed by the cursor clamp across wide spacers
(#2272), combining marks paint so decomposed `é` matches precomposed (#2279),
kitty font query and `bitty +show-font` (#2277), bounded native clipboard
acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the
`bitty.history` Lua surface (#2268), the production ComponentBroker plus
activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI
fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor
reservation (#2289).

Partials are marked honestly: #2254's request surface is still pending, the
#2213 disposition stays open, #2286 is feature-gated and unwired, the macOS
clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not
claimed because PR #2292 is unmerged. The heading reads `unreleased` because
the release is on hold; the tag date is set at tag time.

Docs-only: no code, scripts, workflows, or pins touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:render Area: rendering bug Something isn't working P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.0.24] background_fit fill/fit geometry inverted

1 participant