Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUI window transparency #5040

Closed
1 task done
jansol opened this issue Jan 18, 2023 · 17 comments
Closed
1 task done

GPUI window transparency #5040

jansol opened this issue Jan 18, 2023 · 17 comments
Labels
enhancement [core label] gpui GPUI rendering framework support setting Feedback for preferences, configuration, etc workspace Feedback for workspace management, layout, interactions, etc

Comments

@jansol
Copy link
Contributor

jansol commented Jan 18, 2023

Check for existing issues

  • Completed

Describe the feature

I don't have access to the alpha so not sure if this is supported but judging from screenshots it does not seem to be the case.

It would be very nice to have the option to make the background of zed windows slightly transparent, similarly to my current go-to setup of running neovim in alacritty with 75% background opacity.

Besides the obvious aesthetic that blends in nicely with almost any wallpaper/theme, this also allows me to put an actively updating window behind the editor (either an unrelated application or something that is hot reloading the file I am editing). The background dims the window behind the editor enough so it does not distract from editing, but still allows me to monitor the changes in the other window live without having to sacrifice editing space or alt+tabbing around.

At least on Linux it is sometimes possible to request the compositor to adjust the opacity of specific windows, but that also makes text transparent. For readability it would be important that the application handles background transparency by itself, so text and important UI symbols can remain fully opaque. The main gotcha with this appears to be that different platforms have different requirements for transparent windows (e.g. macOS wants non-premultiplied alpha, Wayland wants premultiplied).

If applicable, add mockups / screenshots to help present your vision of the feature

image

@jansol jansol added enhancement [core label] triage Maintainer needs to classify the issue labels Jan 18, 2023
@JosephTLyons JosephTLyons added workspace Feedback for workspace management, layout, interactions, etc setting Feedback for preferences, configuration, etc and removed triage Maintainer needs to classify the issue labels Jan 19, 2023
@SilentGlasses
Copy link

To each their own but why would you want transparency on an editor? Terminal I can understand to a point.

Pretty sure there will be an option at some point but nothing that I've seen as yet.

The docs are all here by the way...
https://zed.dev/docs/configuration/configuring-zed

@jansol
Copy link
Contributor Author

jansol commented Jan 25, 2023

Why would a GUI text editor be different from a terminal? (especially if the main function of the terminal is... running a text editor)

There are some practical uses for it like mentioned in the OP (hot reloading apps e.g. for shaders, api references, research papers outlining an algorithm I'm in the middle of implementing, ...) and sometimes I simply enjoy the mood set by my desktop wallpaper while being productive in a maximized editor window.

@evrensen467
Copy link
Contributor

Support for window transparency and blurring is something I personally expect in any modern IDE or Text Editor, unfortunately in VSCode's case we have to use an extension, which makes the whole process hacky as we have to inject custom attributes to the built CSS.

I'd like to propose being able to control every panels transparency and blur effect from the settings, giving the option for full window transparency (e.g all panels are transparent), and also to the users who likes the macOS standard, to only have the sidebars transparent with blur (similar to Xcode).

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@WilliamWelsh
Copy link

+1 ! for window transparency and blur

@jansol
Copy link
Contributor Author

jansol commented Feb 7, 2024

Reminder that issue popularity is programmatically tracked based on 👍 reactions to the top post, not by comments.

@zed-industries zed-industries deleted a comment from WilliamWelsh Feb 8, 2024
@jansol jansol mentioned this issue Feb 12, 2024
1 task
@JosephTLyons JosephTLyons added the gpui GPUI rendering framework support label Feb 13, 2024
@JosephTLyons JosephTLyons changed the title Window transparency GPUI Window transparency Feb 13, 2024
@JosephTLyons JosephTLyons changed the title GPUI Window transparency GPUI window transparency Feb 13, 2024
@jansol
Copy link
Contributor Author

jansol commented Feb 17, 2024

Since blur is a particularly popular component to this request, the platform-specific features for implementing that appear to be:

  • macOS:
    • NSVisualEffectView Apple's way or the highway - note that the original configuration values for the view got deprecated very quickly
    • What they don't want you to know is the (apparently) widely used undocumented CGSSetWindowBackgroundBlurRadius(runtime::AnyObject, NSInteger, i64)
  • Windows:
  • Linux/Wayland: (plain alpha blending is part of Wayland core)
    • org_kde_kwin_blur seems to be the only application-controlled way that is actually usable somewhere
    • ext_blur_v1 based on org_kde_kwin_blur so migrating should be easy once this gets accepted
    • Some compositors have their own blur settings, but those are generally not directly controllable by the application
    • Some compositors are explicitly against having blur support
  • Linux/X11:

@jansol
Copy link
Contributor Author

jansol commented Feb 20, 2024

So upon further inspection I concluded that the only somewhat consistent solution across platforms is:

  • The undocumented CGSSetWindowBackgroundBlurRadius (should be safe as long as Terminal.app relies on it)
  • DWM_BLURBEHIND
  • org_kde_kwin_blur/ext_blur_v1

The NSVisualEffectView and Acrylic/Mica materials have Opinions that are based on the system theme (tint towards bright/dark), which gets very awkward unless one designs separate themes for dark and light mode and automatically switches based on the active system theme. Additionally such themes would not really look the intended way on platforms other than the one they were created on. OTOH with the plain blur the theme can specify a semitransparent background color to tint the background in the desired way.

I started working on the somewhat portable solution (well, the macOS part of it - PR coming as soon as I have time to clean it up a bit), but I won't be touching the more platform specific ones. Those should be easy enough to add as alternatives later on if someone feels like they would be good to have.

@Luk4h
Copy link
Contributor

Luk4h commented Mar 19, 2024

Hello @jansol, a lover of the transparent look here as well. I would like to know how is your progress so far? I tried myself to achieve something and so far I got to render the blurred/transparent view below the zed view. I believe meaning if we got to remove the background of the zed view, to see the blurred/transparent background. I am not very comfortable with rust, which made a bit hard for me to find anything related to the zed background, at least not relevant. And my tries with applying a transparent background with themes was not successful as well. I believe this would be the first step to achieve the style we are looking for, later we would need to create a way to toggle this, since most users do not want it. I would love to contribute to this feature since I love the look. If you are willing to collaborate, or anyone else interested. Hit me up. I have forked the zed repo with my progress.

@jansol
Copy link
Contributor Author

jansol commented Mar 20, 2024

@Luk4h I got it working with the CGSSetWindowBackgroundBlurRadius approach, which turned out to be much simpler more convenient for theming than NSVisualEffectView. Right now my implementation is mainly stuck in figuring out how to do the plumbing from the theme to the GPUI window. I've made some decent progress with that, but it's still missing some bits before it's ready for a PR.

@Luk4h
Copy link
Contributor

Luk4h commented Mar 20, 2024

@jansol Are you able to share your work? Interested in seeing your approach, since It was what I aimed for, but got lost and ended up using the NSVisualEffectView, which can't get it to work together with the CAMetalLayer.

maxdeviant added a commit that referenced this issue Mar 29, 2024
This PR adds support for transparent and blurred window backgrounds on
macOS.

Release Notes:

- Added support for transparent and blurred window backgrounds on macOS
([#5040](#5040)).
- This requires themes to specify a new `background.appearance` key
("opaque", "transparent" or "blurred") and to include an alpha value in
colors that should be transparent.

<img width="913" alt="image"
src="https://github.com/zed-industries/zed/assets/2588851/7547ee2a-e376-4d55-9114-e6fc2f5110bc">
<img width="994" alt="image"
src="https://github.com/zed-industries/zed/assets/2588851/b36fbc14-6e4d-4140-9448-69cad803c45a">
<img width="1020" alt="image"
src="https://github.com/zed-industries/zed/assets/2588851/d70e2005-54fd-4991-a211-ed484ccf26ef">

---------

Co-authored-by: Luiz Marcondes <luizgustavodevergennes@gmail.com>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
@JosephTLyons
Copy link
Contributor

This is now available in v0.130.0-pre.

@krstp
Copy link

krstp commented Apr 4, 2024

A snippet of code that show a guidance how to properly implement it would be much appreciated. It is not exactly clear how to leverage it correctly. Thanks.

@Luk4h
Copy link
Contributor

Luk4h commented Apr 4, 2024

A snippet of code that show a guidance how to properly implement it would be much appreciated. It is not exactly clear how to leverage it correctly. Thanks.

On the patch notes it mentions how to specify the new property. You can also override it using the "experimental.theme_overrides" property on your settings file.

@ThatOneCalculator
Copy link
Contributor

Any chance we could get this on Linux too?

@gldtn gldtn mentioned this issue Apr 10, 2024
17 tasks
@xcrap
Copy link

xcrap commented Apr 11, 2024

Screenshot 2024-04-11 at 01 54 33

Still have to fix some borders, but looks so sweet :)

@evwltrs
Copy link

evwltrs commented Apr 13, 2024

image

For the impatient Gruvbox users like me based off @xcrap's config.

"experimental.theme_overrides": {
    "background.appearance": "blurred",
    "background": "#4c464290",
    "editor.background": "#00000030",
    "editor.gutter.background": "#00000030",
    "tab_bar.background": "#00000030",
    "terminal.background": "#00000030",
    "toolbar.background": "#00000030",
    "tab.active_background": "#28282820",
    "tab.inactive_background": "#00000000",
    "status_bar.background": "#00000030",
    "title_bar.background": "#00000030",
    "panel.background": "#00000030",
    "border.variant": "#00000000",
    "scrollbar.track.border": "#00000000",
    "editor.active_line.background": "#00000000"
  }

@jansol
Copy link
Contributor Author

jansol commented May 6, 2024

Linux support for transparent and blurred windows has been merged in #10973

Blur is only supported on Wayland with compositors supporting the kde-blur protocol for now -- i.e. Plasma.

On X11 it may be possible to configure a compositor to blur window backgrounds but Zed has no way to influence that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] gpui GPUI rendering framework support setting Feedback for preferences, configuration, etc workspace Feedback for workspace management, layout, interactions, etc
Projects
None yet
Development

No branches or pull requests

10 participants