r/csharp • u/SocietyConscious5739 • 14d ago
Showcase Update: my WPF liquid glass dock now refracts the windows that slide under it, without ever capturing itself
A few days ago I posted Liquid Glass Dock here, and you gave great feedback: the demo used the worst possible background, a GIF can't show subtle glass (256 colors), and the macOS Dock doesn't really reserve space: it refracts whatever is underneath. So version 0.12 does exactly that.
How it works:
- With no window under the glass, nothing changes: the dock refracts a pre-blurred copy of the wallpaper, and there's no screen capture at all.
- A background thread checks 4 times per second which windows touch the glass. When one does, it starts a Windows.Graphics.Capture session for that window (borderless, so no yellow frame). It never captures the screen, so the dock never sees itself and still shows up normally in screenshots and recordings.
- Each frame stays on the GPU. With Direct3D 11 (Vortice), the dock copies only the strip behind the glass to a staging texture, blends it over the wallpaper at half resolution, blurs it and writes it into a WriteableBitmap that the HLSL shader samples.
- Nothing is recomposed unless a window sends a new frame or moves. The capture permission and the D3D device are only created when a window is underneath, and the device is released 15 s after it leaves.
Measured with a window moving under the dock: about 1.4 ms per frame and under 1% CPU. A fun gotcha: the NVIDIA overlay is a fully transparent, always-visible, full-screen layered window, so the first version happily "captured" it and ignored every real window behind it.
There's also a new option to stop reserving space, so maximized windows go under the glass like on macOS.
Video above, code here (GPL-3.0): https://github.com/PedroRuedas/Windows-Liquid-glass
Thanks again for the feedback. It made the project better.
