feat: add liquid glass background effect support
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
50% Opacity, Transparent
0% Opacity, Transparent
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 blurregular-glassandclear-glass: Liquid Glass effect (implemented by this PR)- other
NSVisualEffectViewstyles
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!)
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?
Any updates on this PR?
Just waiting on a review, happy to make any changes the maintainers see fit.
Question out of curiosity: Will this respect the system wide reduce transparency setting?
Question out of curiosity: Will this respect the system wide reduce transparency setting?
Yes. NSGlassEffectView (and NSVisualEffectView) respects "Reduce Transparency" settings.
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 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
macos-background-style = regular-glass
Aha! Thanks for the pointer, that completely slipped by me because of the debug indicator. I have the fix:
Anything left before being merged? Really excited for this PR.
Seconded @insomnia-creator. I'm happy to fix conflicts myself if it helps to move this closer to release.
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.
The blur change makes sense, thank you for reviewing and solidifying the PR! Looking forward to using it in my Ghostty soon ❤️
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.