Skip to content

qt: fix window flashing white when opened, resize artifact, and re-enable Windows 11 22H2 native acrylic backdrop effect

Fatih Uzunoğlu requested to merge fuzun/vlc:qt/windowsnoredirection into master

In !6297 (merged), I started checking for frameless window hint because for the native acrylic effect, the UI needs to be transparent (the window itself should pass through as that's the effect provider) but when the window has a frame and the window is not layered, there is usually an initial Win32 white background due to WNDCLASSEX::hbrBackground (which has the size of the initial window size) which is not cleared until resized. And resizing the window first exposes it until Qt Quick draws the scene to the new extents, as well as the first opening a white flash occurs (QTBUG-106583). Note that the scene graph can not clear this background with the graphics API clear color for obvious reasons (QTBUG-98122), so if the interface is transparent that white background shows up in the background in stationary situation, currently the interface is not transparent (there is either video visual or opaque simulated acrylic effect visual beneath the UI visual, or the interface (clear) color is opaque).

Since the interface window always has a frame (even with CSD), !6297 (merged) de facto disabled using the native Windows 11 22H2 acrylic effect in order to eliminate this artifact, as for the native effect the UI visual must be transparent.

Maybe layered window (WS_EX_LAYERED) could work out to get rid of this white background even though the new native effect does not require the window to be transparent, but that meant worse performance.

With WS_EX_NOREDIRECTIONBITMAP, there will be no background (see Fig. 2 of [1]), not only this would fix the white background artifact and make it possible to use the native window effect, it has the advantage of increasing the performance due to not copying buffers [1].

I have tested this with Nvidia on Windows 11, ideally it should be tested with other GPUs as well. I have also tested it on Windows 10 VM.

Also, doing a naive global search on GitHub shows that many projects have started using WS_EX_NOREDIRECTIONBITMAP.

Request review @chub. Ping @jbk.

[1] https://learn.microsoft.com/en-us/archive/msdn-magazine/2014/june/windows-with-c-high-performance-window-layering-using-the-windows-composition-engine

Merge request reports

Loading