ghostty icon indicating copy to clipboard operation
ghostty copied to clipboard

feat: add liquid glass background effect support

Open Lustyn opened this issue 3 months ago • 11 comments

Description

This PR implements the basic functionality for "Liquid Glass" style background support (#8155). I used OpenCode (Claude 4) in some capacity to write this as I'm not super familiar with AppKit / SwiftUI. A good chunk of this I still needed to write by hand since Claude doesn't understand the Glass APIs, but I'm not 100% if the implementation here makes the best decisions since the practices in Ghostty config and separation of the AppKit code and SwiftUI seemed inconsistent to me.

Some of the combinations of options obviously create entirely unreadable terminals, but I've found that regular glass and transparent with opacity to be fairly readable. We don't enable this feature by default since it would of course break existing users setups.

Open Questions

  • [x] How to determine the correct cornerRadius? For now this is eyeballed, I can't see any macOS public API or clearly documented constants.
  • [x] Should boolean options be exposed for reasonable defaults?
  • [x] Should the option need to be namespaced to macos-*?

Screenshots

0% Opacity, Regular image 50% Opacity, Transparent image 0% Opacity, Transparent image

Lustyn avatar Sep 20 '25 05:09 Lustyn

How to determine the correct cornerRadius? For now this is eyeballed, I can't see any macOS public API or clearly documented constants.

https://www.reddit.com/r/MacOSBeta/comments/1lb2jt5/window_corner_radius_in_macos_tahoe_depends_on/ They are fixed. You can do a simple switch-case on the config macos-titlebar-style: 16pt for native, transparent and hidden, 20pt for tabs.

Should the option need to be namespaced to macos-*?

IMHO the config should not be limited to Liquid Glass effect. A better config name would be macos-background-style with following options:

  • default: uses regular blur
  • regular-glass and clear-glass: Liquid Glass effect (implemented by this PR)
  • other NSVisualEffectView styles

Aaron-212 avatar Sep 20 '25 11:09 Aaron-212

Thanks for the find on the corner radius!

I think vibrancy / NSVisualEffect is a good call out for how this feature should be structured. On the blur option I'm a bit unsure of since in the current state this allows users to mix glass, traditional blur, and opacity to achieve a little more readability.

(But if we have reasons we think mixing them is a no-no, that's ok!)

Lustyn avatar Sep 20 '25 15:09 Lustyn

For now I've made standalone blur and the glass effects mutually exclusive, likewise I think the same would be true of NSVisualEffect if I understand correctly. My thoughts are that this will reduce confusion for people enabling the glass effect that already have a blur value set. A blur + glass merged mode or override might make more sense for users that actually intend on doing that?

Lustyn avatar Sep 20 '25 18:09 Lustyn

Any updates on this PR?

insomnia-creator avatar Oct 05 '25 10:10 insomnia-creator

Just waiting on a review, happy to make any changes the maintainers see fit.

Lustyn avatar Oct 05 '25 17:10 Lustyn

Question out of curiosity: Will this respect the system wide reduce transparency setting?

tisba avatar Oct 06 '25 17:10 tisba

Question out of curiosity: Will this respect the system wide reduce transparency setting?

Yes. NSGlassEffectView (and NSVisualEffectView) respects "Reduce Transparency" settings.

Aaron-212 avatar Oct 07 '25 11:10 Aaron-212

image

I don't think I'm able to reproduce that. Looks fine on my end after your rebase. Is this only an issue on earlier macOS versions?

Lustyn avatar Oct 12 '25 23:10 Lustyn

@Lustyn I think the issue is that the color/transparency of the titlebar isn't identical to the terminal surface, so you get a style break. IIUC the solution is just to make the tabs titlebar fully transparent when the glass effect is enabled, like you do for surface rendering. The same probably goes for the macos-titlebar-style = transparent variant.

macos-background-style = default Screenshot 2025-10-17 at 11 04 54

macos-background-style = regular-glass Screenshot 2025-10-17 at 11 05 49

danielwe avatar Oct 17 '25 18:10 danielwe

Aha! Thanks for the pointer, that completely slipped by me because of the debug indicator. I have the fix: image

Lustyn avatar Oct 18 '25 01:10 Lustyn

Anything left before being merged? Really excited for this PR.

insomnia-creator avatar Nov 22 '25 05:11 insomnia-creator

Seconded @insomnia-creator. I'm happy to fix conflicts myself if it helps to move this closer to release.

Tankenstein avatar Dec 06 '25 17:12 Tankenstein

I should note that I suspect this may cause some edge cases with custom shaders and may impact alpha blending as noted above. I think highlighting this in the docs is the way to go just to give people the creative freedom to have this style if they want it if they don't care about those other features. It's default off and very much an optional thing so I think that's alright.

mitchellh avatar Dec 15 '25 19:12 mitchellh

The blur change makes sense, thank you for reviewing and solidifying the PR! Looking forward to using it in my Ghostty soon ❤️

Lustyn avatar Dec 16 '25 17:12 Lustyn

not sure if this is a bug with implementation or just a quirk of liquid glass (either way would like to work towards some fix), but the appearance between focused and unfocused windows is extremely jarring.

image

8pxl avatar Dec 18 '25 03:12 8pxl