Skip to content

Conversation

qwerasd205
Copy link
Member

@qwerasd205 qwerasd205 commented Jun 25, 2025

Adds support for background images via the background-image config.

Resolves #3645, supersedes PRs #4226 and #5233.

See docs of added config keys for usage details.

Note

Unlike what is implied by the original issue, because this is implemented in the renderer it is inherently per-surface not per-window, meaning a window with a split will have two copies of the background image.

Future work

  • We should probably introduce code in the apprts that tells surfaces their position and size relative to the window, which would allow us to add a background-image-area config with options for surface and window to control that behavior (and probably default it to window). That apprt code would also allow for window-relative custom shader locations, which is also a fairly common user request, so I think it's worth it.
  • Currently if you use a high res background image this is fairly inefficient, since each surface independently loads a copy of the background image. On systems with limited VRAM this could be an issue for users who use a lot of surfaces, so it may be worth making a shared image cache to avoid this problem.
  • It's probably worth using compressed texture formats for images, I'll look in to doing that. (c43702c)

@qwerasd205 qwerasd205 requested a review from a team as a code owner June 25, 2025 15:45
@qwerasd205
Copy link
Member Author

Turns out using compressed image formats is a trivial change (already happens automagically on Metal and it's just a few lines different on OpenGL), so I'll add that as a commit to this PR.

@mitchellh
Copy link
Contributor

We should probably introduce code in the apprts that tells surfaces their position and size relative to the window, which would allow us to add a background-image-area config with options for surface and window to control that behavior (and probably default it to window). That apprt code would also allow for window-relative custom shader locations, which is also a fairly common user request, so I think it's worth it.

Yes, but I want to do this in a slightly more thoughtful way. The core needs to be come generally layout aware to enable a number of features:

  • tmux control mode
  • save/restore layouts
  • single background
  • custom shader awareness for splits

Probably more. So we should do this in a way that knocks all those out, I think.

Currently if you use a high res background image this is fairly inefficient, since each surface independently loads a copy of the background image. On systems with limited VRAM this could be an issue for users who use a lot of surfaces, so it may be worth making a shared image cache to avoid this problem.

Yes, we should do this similar to how we do our font grid. Future PR.

qwerasd205 and others added 5 commits June 25, 2025 16:27
Adds support for background images via the `background-image` config.

Resolves ghostty-org#3645, supersedes PRs ghostty-org#4226 and ghostty-org#5233.

See docs of added config keys for usage details.
BPTC is required to be available OpenGL >= 4.2 and our minimum is 4.3 so
this is safe in terms of support. I tested briefly in a VM and didn't
encounter any problems so this should just be a complete win.

(Note: texture data is already automatically compressed on Metal)
Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

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

I rebased and I updated the background-image docs to have a lot more details and note the VRAM issue.

@mitchellh mitchellh enabled auto-merge June 25, 2025 20:27
@mitchellh mitchellh merged commit 9eec80e into ghostty-org:main Jun 25, 2025
38 checks passed
@github-actions github-actions bot added this to the 1.2.0 milestone Jun 25, 2025
@qwerasd205 qwerasd205 deleted the bg-image branch June 26, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window background image configuration option
3 participants