fix(terminal): pass physical pixels to ghostty_surface_set_size on HiDPI#100
Open
PavloGrubyi wants to merge 1 commit into
Open
fix(terminal): pass physical pixels to ghostty_surface_set_size on HiDPI#100PavloGrubyi wants to merge 1 commit into
PavloGrubyi wants to merge 1 commit into
Conversation
The GtkGLArea framebuffer is sized in physical pixels (logical * scale_factor), and ghostty_surface_set_size expects physical pixels — the OpenGL renderer compares the value against GL_VIEWPORT and presents an empty (black) frame on mismatch. refresh_surface_display() was passing logical CSS pixels, so at any scale_factor != 1 (e.g. 200% HiDPI / fractional scaling) the terminal pane rendered solid black while chrome rendered fine. Multiply the allocation by scale_factor() so ghostty receives the true framebuffer size. content_scale is unchanged (it drives font DPI). Fixes am-will#99. Related: am-will#82.
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.
Problem
On any GTK
scale_factor != 1(e.g. 200% HiDPI, or fractional scaling), the embedded Ghostty terminal pane renders solid black while the GTK chrome (sidebar, tabs, toolbar) renders fine. The shell underneath is alive the whole time (limux read-screenshows content,surface-healthreports healthy) — only the on-screen GL paint is missing. At 100% scale it renders correctly.This reproduces independent of GPU/driver/renderer/session: verified black with NVIDIA, with pure Mesa llvmpipe software rendering, under
GSK_RENDERER=gl/ngl/software, and on both native Wayland and XWayland. It matches #99 (reported on non-NVIDIA Mint/Cinnamon) and #82 (Wayland fractional scaling clip).Root cause
refresh_surface_display()inrust/limux-host-linux/src/terminal.rspassesgl_area.allocation()— logical/CSS pixels — toghostty_surface_set_size. But that API expects physical pixels (the GL framebuffer size): the OpenGL renderer reads the real size fromGL_VIEWPORTand, on a mismatch between the set size and the viewport, presents the previous (empty) frame and returns early — a black pane. TheGtkGLAreaframebuffer is physical-sized (logical * scale_factor), so at scale 1 logical == physical and it works, while at scale 2 the renderer is told 800×600 but the viewport is 1600×1200 → permanent mismatch → black.Fix
Multiply the allocation by
scale_factor()so Ghostty receives the true framebuffer dimensions.content_scaleis unchanged (it drives font DPI). One call site; grep-confirmed there are no others.Testing
Built and verified on Ubuntu 24.04 / GNOME 46 Wayland / NVIDIA / 4K @ 200%: terminal pane now renders correctly at 200% (and still at 100%). Live-switching the display scale 100%↔200% repaints correctly via the existing
connect_resizepath.Fixes #99. Related: #82.