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

Blade window transparency #10973

Merged
merged 9 commits into from May 6, 2024
Merged

Conversation

kvark
Copy link
Contributor

@kvark kvark commented Apr 25, 2024

Release Notes:

  • N/A

Following up to #10880
TODO:

  • create window as transparent
    • X11
    • Wayland
    • Windows
    • MacOS (when used with Blade)
  • enable GPU surface transparency
  • adjust the pipeline blend modes
  • adjust shader outputs

transparency2

Blurred results from @jansol (on Wayland), who contributed to this work:

zed-blur

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Apr 25, 2024
@kvark kvark force-pushed the blade-transparency branch 3 times, most recently from 3920df8 to ec1f3fd Compare April 25, 2024 07:01
@kvark kvark force-pushed the blade-transparency branch 6 times, most recently from 4d1206e to 612287b Compare April 28, 2024 17:16
@ThatOneCalculator
Copy link
Contributor

Progress? 👀 (Hyprland with wlroots)

image

@kvark kvark force-pushed the blade-transparency branch 2 times, most recently from aa2c028 to 4f17e87 Compare May 2, 2024 05:00
@kvark
Copy link
Contributor Author

kvark commented May 2, 2024

Pushed the X11 changes here, but it currently doesn't start. Vulkan surface creation fails with VK_ERROR_OUT_OF_HOST_MEMORY. Looking at the Mesa source, it appears to throw this error pretty much on anything that goes wrong, without necessarily logging the reason anywhere.

@kvark kvark force-pushed the blade-transparency branch 2 times, most recently from bce6916 to 69f786c Compare May 2, 2024 07:12
@kvark
Copy link
Contributor Author

kvark commented May 2, 2024

It doesn't like the Visual I'm choosing, for some reason. Here is the visual selected by default, where it works:

Using Visual id: 66, class: TRUE_COLOR, depth: 24, bits_per_component: 8, colormap: 65, masks: 0xff0000, 0xff00, 0xff

And here is the opaque Visual I got by scanning the compatible ones:

Using Visual id: 975, class: DIRECT_COLOR, depth: 24, bits_per_component: 8, colormap: 0, masks: 0xff0000, 0xff00, 0xff

Also, here is the transparent Visual I got, which also doesn't work:

Using Visual id: 751, class: TRUE_COLOR, depth: 32, bits_per_component: 8, colormap: 0, masks: 0xff0000, 0xff00, 0xff

I can see that it's not about TRUE_COLOR versus DIRECT_COLOR, and not about depth, and not about color masks (which are the same in all cases). The only strange thing is - default format having a color map.
I suspect that not all of the visuals are compatible with Vulkan surface, but I don't know how to detect it.

@kvark kvark marked this pull request as ready for review May 6, 2024 05:15
@kvark
Copy link
Contributor Author

kvark commented May 6, 2024

I got stuck for too long with this issue on X11, which turned out to be quite an adventure!

I looked closely at all of the existing X11 examples and also at Blade examples, which worked. Discovered that winit is still producing RawWindowHandle::Xlib even though using Xcb - rust-windowing/winit#3681
I tried following the cairo example by querying formats and seeing what visual IDs are associated.
I tried different Visual IDs by hand and confirmed that I'm failing on the same ones that work via different paths...
I tried compiling RadV (AMD's driver) locally and running with it, stepping through in a debugger, to discover that it failed on simple queries about the given window (like, who is your father?).
This led me to double check all of the things we do at window creation and conclude that the window was created as invalid in the first place, and we weren't properly checking for it. Of course creating a Vulkan surface would fail in this case!

Finally, I found out that border_pixel setting was missing comparing to winit's path. Also related to this StackOverflow discussion. This was the last missing piece, and now everything appears to work in order, finally!
Small achievement, but at great cost :)

@mikayla-maki
Copy link
Contributor

mikayla-maki commented May 6, 2024

Looks great, thank you so much @kvark

Also, yikes, that X11 bug looks gnarly. Thanks for tracking that one down :D

@mikayla-maki mikayla-maki merged commit e4f13dd into zed-industries:main May 6, 2024
10 checks passed
@mikayla-maki
Copy link
Contributor

Merging without windows support as we're not officially working on Windows yet. If folks want to follow up, feel free!

@jansol jansol mentioned this pull request May 6, 2024
1 task
@ThatOneCalculator
Copy link
Contributor

Nice! One minor issue I'm noticing is that the selected item in the file sidebar shows as solid white

image

  "experimental.theme_overrides": {
    "background.appearance": "blurred",
    "background": "#191724BB",
    "editor.background": "#00000030",
    "editor.gutter.background": "#00000030",
    "tab_bar.background": "#00000030",
    "terminal.background": "#00000030",
    "toolbar.background": "#00000030",
    "tab.active_background": "#26233a90",
    "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"
  },

mikayla-maki pushed a commit that referenced this pull request May 6, 2024
@kvark kvark deleted the blade-transparency branch May 7, 2024 04:24
JunkuiZhang added a commit to JunkuiZhang/zed that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants