Skip to content

fix(host-linux): send physical pixels to ghostty_surface_set_size#95

Open
tnfssc wants to merge 1 commit into
am-will:mainfrom
tnfssc:main
Open

fix(host-linux): send physical pixels to ghostty_surface_set_size#95
tnfssc wants to merge 1 commit into
am-will:mainfrom
tnfssc:main

Conversation

@tnfssc

@tnfssc tnfssc commented Jun 2, 2026

Copy link
Copy Markdown

Fixes terminal sizing on HiDPI / fractional-scale displays.

Problem

returns CSS/logical pixels, but expects physical device pixels. On screens with scale factor > 1 (e.g. laptops, fractional scaling) this caused:

  • Terminal rendering in a tiny sub-rectangle of the GL viewport
  • Zero-column grid when opening on the laptop screen alone

Fix

  • Multiply allocation by before calling in realize, resize, and scale-factor-notify handlers.
  • Add explicit handler so moving a window between monitors with different DPI updates the surface correctly even when the logical allocation does not change.

Copilot AI review requested due to automatic review settings June 2, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Ghostty surface sizing to use device-pixel dimensions in GTK GLArea, including explicit refreshes on scale-factor changes to keep rendering crisp under HiDPI / fractional scaling scenarios.

Changes:

  • Refactors refresh_surface_display to accept explicit width/height (device pixels) instead of reading GLArea allocation internally.
  • Computes device-pixel size using allocation × scale factor for initial realization and realized refresh paths.
  • Adds a scale-factor notify handler to refresh Ghostty’s content scale/size when only the backing pixel density changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/limux-host-linux/src/terminal.rs
Comment thread rust/limux-host-linux/src/terminal.rs Outdated
Comment thread rust/limux-host-linux/src/terminal.rs
GLArea::allocation() returns CSS/logical pixels, but
ghostty_surface_set_size expects physical device pixels.
On HiDPI screens this caused the terminal to render at a
fraction of the GL viewport or with a zero-size grid.

Changes:
- Introduce gl_area_device_size() helper to convert logical
  allocation to device pixels (allocation * scale_factor).
- Use explicit device_width/device_height parameter names in
  refresh_surface_display and add rustdoc to prevent accidental
  logical-pixel usage.
- Add connect_scale_factor_notify handler with a last-device-size
  cache to avoid redundant refresh/render cycles when the notify
  fires without an actual size change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants