I'm building a macOS style dock for Windows as a side project. It's plain Win32 C++, one exe: https://github.com/Moryel/JustBetterTaskBar
The dock background is frosted glass right now. It's a window with WS_EX_NOREDIRECTIONBITMAP, a DesktopWindowTarget, and a sprite visual whose brush is a HostBackdropBrush with a saturation effect on top. Trimmed down, it's this:
```cpp
HWND wnd = CreateWindowExW(WS_EX_NOREDIRECTIONBITMAP | WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_NOACTIVATE,
L"GlassWnd", L"", WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, hinst, nullptr);
BOOL t = TRUE;
DwmSetWindowAttribute(wnd, 17 /*DWMWA_USE_HOSTBACKDROPBRUSH*/, &t, sizeof t);
auto interop = compositor.as<ABI::Windows::UI::Composition::Desktop::ICompositorDesktopInterop>();
winrt::check_hresult(interop->CreateDesktopWindowTarget(wnd, true,
reinterpret_cast<ABI::Windows::UI::Composition::Desktop::IDesktopWindowTarget**>(winrt::put_abi(target))));
auto visual = compositor.CreateSpriteVisual();
auto geo = compositor.CreateRoundedRectangleGeometry();
visual.Clip(compositor.CreateGeometricClip(geo));
target.Root(visual);
auto backdrop = compositor.CreateHostBackdropBrush();
winrt::Windows::UI::Composition::CompositionEffectSourceParameter src(L"backdrop");
auto fx = winrt::make<SaturationEffect>(1.8f, src); // custom IGraphicsEffectD2D1Interop
auto brush = compositor.CreateEffectFactory(fx).CreateBrush();
brush.SetSourceParameter(L"backdrop", backdrop);
visual.Brush(brush);
```
That works fine. What I want now is something like Apple's Liquid Glass: lighter blur, and the content behind gets bent near the edges like a lens.
The problem is that HostBackdropBrush already gives me the backdrop blurred, so there's nothing sharp left to displace. I also couldn't find a displacement effect that CreateEffectFactory accepts.
These are the two options I can see:
Capture the monitor area under the dock with Windows.Graphics.Capture and set WDA_EXCLUDEFROMCAPTURE on my own windows so they don't show up in it. Then run my own D3D11 pixel shader on the captured texture for the blur, the edge displacement and a rim highlight, and present it through a swap chain. My worries here: memory probably goes from ~12 MB to 40-60 MB, the yellow capture border might show up on some setups, and a constant capture loop just feels heavy for something that's always on screen.
Skip real refraction. Keep the HostBackdropBrush and just draw highlights and gradients on top. Cheap, but it only looks "kind of" like it.
My actual questions:
- Is there any way to get the unblurred backdrop from DWM or Composition without capturing the screen myself?
- If capture is the only way, is running Graphics.Capture continuously in an always-on-top window reasonable performance-wise? Has anyone done it?
- And can the capture border be turned off reliably for an unpackaged Win32 app?
Thanks in advance.