From cddd76eb9d204b8a5bd63a2907d9269fc2d5f272 Mon Sep 17 00:00:00 2001 From: Pavlo Grubyi Date: Fri, 5 Jun 2026 21:38:04 +0100 Subject: [PATCH] fix(terminal): pass physical pixels to ghostty_surface_set_size on HiDPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #99. Related: #82. --- rust/limux-host-linux/src/terminal.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rust/limux-host-linux/src/terminal.rs b/rust/limux-host-linux/src/terminal.rs index 4bd00101..58986d80 100644 --- a/rust/limux-host-linux/src/terminal.rs +++ b/rust/limux-host-linux/src/terminal.rs @@ -414,12 +414,16 @@ fn request_terminal_focus(gl_area: >k::GLArea, had_focus: &Cell) { fn refresh_surface_display(surface: ghostty_surface_t, gl_area: >k::GLArea) { let alloc = gl_area.allocation(); - let w = alloc.width() as u32; - let h = alloc.height() as u32; + let scale = gl_area.scale_factor(); + // ghostty_surface_set_size expects PHYSICAL pixels (the GL framebuffer size). + // gl_area.allocation() returns LOGICAL CSS pixels; multiply by the integer + // scale factor to get the physical pixel dimensions that match the GL viewport. + let w = (alloc.width() * scale) as u32; + let h = (alloc.height() * scale) as u32; if w > 0 && h > 0 { - let scale = gl_area.scale_factor() as f64; + let scale_f64 = scale as f64; unsafe { - ghostty_surface_set_content_scale(surface, scale, scale); + ghostty_surface_set_content_scale(surface, scale_f64, scale_f64); ghostty_surface_set_size(surface, w, h); } }