fix(render): DPI-scale terminal padding and border offsets#240
fix(render): DPI-scale terminal padding and border offsets#240forketyfork merged 3 commits intomainfrom
Conversation
Issue: After border thickness was increased and DPI-scaled in a recent PR, two layout bugs showed up in grid view on Retina displays: the CWD bar overlapped the bottom border, and the border drew over terminal content. Solution: The CWD bar used the raw grid_border_thickness constant (6 logical px) instead of the DPI-scaled value, so on 2x displays its position was wrong by exactly that difference. Fixed by applying dpi.scale() to the border thickness in reservedHeight() and renderCwdBar(). The terminal_padding constant (8px logical) was also used as raw physical pixels in renderSessionContent, terminalContentRect, and the session interaction hit-testing path. On 2x Retina, the DPI-scaled border (12px) exceeded the unscaled padding (8px), so the border drew over terminal content. Fixed by threading ui_scale through to renderSessionContent and terminalContentRect and applying dpi.scale() to terminal_padding.
There was a problem hiding this comment.
Pull request overview
Fixes DPI-scaling issues in grid view rendering by ensuring border thickness and terminal padding are treated as logical units and scaled to physical pixels via dpi.scale().
Changes:
- DPI-scale
grid_border_thicknessusage in CWD bar layout so it no longer overlaps the bottom border on Retina displays. - DPI-scale
terminal_paddingin terminal content rendering and terminal content rect calculation. - Thread
ui_scaleintorenderSessionContent/terminalContentRectcall paths (renderer + session interaction scrollbar context).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/ui/components/session_interaction.zig | Scales terminal content rect padding for scrollbar layout (now takes ui_scale). |
| src/ui/components/cwd_bar.zig | Scales grid border thickness when reserving height and positioning the CWD bar. |
| src/render/renderer.zig | Scales terminal padding during content rendering and content-rect computation; threads ui_scale into rendering. |
Comments suppressed due to low confidence (1)
src/render/renderer.zig:377
renderSessionContentnow uses DPI-scaledterminal_padding, butterm_cols/term_rowsappear to be computed elsewhere using the unscaled constant. On high-DPI displays this will maketerm_cols/term_rowslarger than what fits indrawable_w/drawable_h, causing the right/bottom of the terminal to be clipped (sincevisible_cols/rowsare capped bymax_*_fit). Consider updating the terminal sizing / PTY pixel size calculations to usedpi.scale(terminal_padding, ui_scale)(or threadingui_scaleinto those helpers) so sizing and rendering stay consistent.
const padding: c_int = dpi.scale(terminal_padding, ui_scale);
const drawable_w: c_int = rect.w - padding * 2;
const drawable_h: c_int = rect.h - padding * 2;
if (drawable_w <= 0 or drawable_h <= 0) return;
const origin_x: c_int = rect.x + padding;
const origin_y: c_int = rect.y + padding;
const max_cols_fit: usize = @intCast(@max(0, @divFloor(drawable_w, cell_width_actual)));
const max_rows_fit: usize = @intCast(@max(0, @divFloor(drawable_h, cell_height_actual)));
const visible_cols: usize = @min(@as(usize, term_cols), max_cols_fit);
const visible_rows: usize = @min(@as(usize, term_rows), max_rows_fit);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 774020911e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Issue: Three review comments on #240 identified that the original fix left raw terminal_padding in terminal PTY sizing (layout.zig) and full-view mouse hit-testing (session_interaction.zig), causing the renderer and these paths to disagree about the content area on high-DPI displays. Solution: Threaded ui_scale through calculateTerminalSize, calculateGridCellTerminalSize, calculateTerminalSizeForMode, and applyTerminalResize in layout.zig so PTY dimensions and pixel sizes match what the renderer actually draws. Updated fullViewCellFromMouse and fullViewPinFromMouse to use the same DPI-scaled padding, so clicks near the border resolve to the correct cell on Retina displays.
Summary
A recent PR increased border thickness and made it DPI-aware. Two layout bugs followed in grid view on Retina displays.
The CWD bar (current directory display) was overlapping the bottom border.
reservedHeight()andrenderCwdBar()both read the rawgrid_border_thicknessconstant (6 logical px) without scaling it, so on 2x displays the bar ended up positioned too high by the scaling difference.The border was also drawing over terminal content.
terminal_padding = 8is a logical pixel value but was used as raw physical pixels throughoutrenderSessionContent,terminalContentRect, and the session interaction hit-testing path. On 2x Retina the DPI-scaled border is 12px, which exceeds the 8px padding, so the border ate into the content area.Both are fixed by applying
dpi.scale()where the raw constants were used. For terminal padding,ui_scaleis now threaded through torenderSessionContentandterminalContentRectin bothrenderer.zigandsession_interaction.zig.Test plan