Repository navigation
Crop kitty placements to their source rect in the native module - #707
Merged
Merged
Conversation
The Elisp callback refused any placement whose source-rect width or height differed from the rendered pixel size. Those are different coordinate spaces: the rect is in image pixels, the rendered size is post-scale, so every scaled placement that named its source rect explicitly (scale-to-fit previews sending w/h as the full image size) raised ghostel-kitty-unsupported-source-rect on each redraw. The check also passed native-size placements that libghostty clips on a scroll inside a margin region, squashing the whole image into the remaining rows. Emacs can only crop post-scale, so the PPM converter now takes the rectangle to emit and the placement path passes libghostty's resolved source rect. The Elisp side receives exactly the sub-image the placement asks for, and pixelSize/gridSize already describe that rect, so the check and the four source-rect arguments are gone. Fixes #706
dakra
force-pushed
the
fix/kitty-source-rect-crop
branch
from
September 19, 2026 14:37
2c58baf to
54cdc07
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.
Fixes #706.
ghostel--kitty-check-source-rectcompared the placement's source-rect width and height (image pixels) against the rendered pixel size (post-scale). Any scaled placement that named its source rect explicitly, such as a scale-to-fit preview sendingw/has the full image size, raisedghostel-kitty-unsupported-source-recton every redraw. The same check also let through native-size placements that libghostty clips when they scroll inside a margin region, squashing the whole image into the remaining rows.Emacs can only crop post-scale, so the crop now happens in the native module: the PPM converter takes the rectangle to emit, and the placement path passes libghostty's resolved
sourceRect. libghostty'spixelSizeandgridSizealready describe that rect, so the Elisp side scales the cropped data into its cells unchanged. The check, the error symbol, and the four source-rect arguments are gone.Virtual (unicode placeholder) placements still receive the whole image, as before.
Verified live in a GUI Emacs: a 160x90 placement with
c=20,r=5,w=160,h=90renders the full image across five rows, andx=80,w=80renders only the right half.