feat(embedded): support GTK OpenGL hosts - #196
Conversation
Restore app-thread rendering and display lifecycle hooks for GTK GLArea embedders while preserving callback-backed OpenGL behavior. Make font query API portable across CoreText and FreeType. Co-authored-by: FreeMeWat <freeme62410@gmail.com>
📝 WalkthroughWalkthroughThis change adds Linux to the embedded platform ABI. It adds Linux-specific drawing and OpenGL context lifecycle handling. It also adds cross-backend font PostScript name and source path accessors. ChangesLinux embedded support
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant HostApplication
participant SurfaceLifecycle
participant OpenGL
participant SurfaceDraw
HostApplication->>SurfaceLifecycle: call ghostty_surface_display_unrealized
SurfaceLifecycle->>OpenGL: release renderer resources
HostApplication->>OpenGL: make GTK context current
HostApplication->>SurfaceLifecycle: call ghostty_surface_display_realized
SurfaceLifecycle->>OpenGL: prepare current embedded context
HostApplication->>SurfaceDraw: draw surface
SurfaceDraw->>OpenGL: drawFrame(false)
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec9b2a0afe
ℹ️ 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".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/font/face/freetype.zig`:
- Around line 193-199: Update the FreeType Face path handling so
initFile-created faces retain their owned source path and urlPath returns it,
while memory-backed faces continue returning null. Ensure synthetic face copies
propagate the stored path and preserve correct buffer handling in urlPath.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d3db61cf-18bf-4453-ab72-a95c90ef1691
📒 Files selected for processing (5)
include/ghostty.hsrc/apprt/embedded.zigsrc/font/face/coretext.zigsrc/font/face/freetype.zigsrc/renderer/OpenGL.zig
Choose app-thread drawing per surface so GTK GLArea uses its owning thread while callback-backed OpenGL keeps its renderer-thread context.
Retain file-backed face paths across synthetic copies so Linux font queries report discovered fonts accurately. Keep memory-backed faces pathless.
Summary
GLArearenderingThis ports the minimal GTK embedding support originally implemented by FreeMeWat onto current
manaflow-ai/ghosttywithout carrying the older fork. The commit retains original authorship credit throughCo-authored-by.Why
GTK
GLAreaowns a main-thread framebuffer. Generic callback-backed OpenGL may render on Ghostty’s renderer thread, so it cannot safely replace this path. Linux also exposed a pre-existing build failure in the font query API because it directly accessed CoreText-only fields.Validation
zig build -Dapp-runtime=none -Doptimize=ReleaseFast -Dcpu=baselinezig build test -Dapp-runtime=none -Dtest-filter="OpenGL presentation preserves"zig build test -Dapp-runtime=none -Dtest-filter="face name"Full unfiltered Ghostty test process was killed with exit 137 on a memory-pressured workstation. Focused changed-path tests pass; downstream Limux full Rust and live GTK smoke gates run separately.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Add Linux GTK
GLAreaembedding for OpenGL with per-surface app-thread rendering and explicit display realize/unrealize hooks. Font queries are now portable across CoreText and FreeType, preserving file paths for file-backed faces on Linux.New Features
GHOSTTY_PLATFORM_LINUXandlinux_platforminghostty.h, plusghostty_surface_display_unrealizedandghostty_surface_display_realized.GLAreadraws on the app thread, uses the current FBO/viewport for size, and lets GTK swap after the render callback; callback-backed OpenGL retains enter/leave andswap_buffers.Bug Fixes
GLAreauses its owning thread while callback-backed OpenGL stays on the renderer thread.urlPathfor file-backed faces; the path is preserved across synthetic bold/italic. Memory-backed faces still have no URL.Written for commit 1a89efa. Summary will update on new commits.
Summary by CodeRabbit