While looking at unrelated bug I figured that move_window_bits_surface() called when surface becomes NULL is actually needed. Just SetPixelFormat() or creating Vulkan surface on a window without yet presenting anything will create client window, and when onscreen client window is used in winex11 that results in black window contents. In this case the surface is deleted, and move_window_bits_surface() restores the contents of the window onscreen while otherwise it will stay black (we also don't invalidate the window in this case which is also correct).
Then, it looks like currently systray window is the only case when we may end up with deleting surface and argb visual. For layered windows only UpdateLayeredWidnow - managed layered windows end up with argb visuals. And for such windows the surface is never destroyed even if 3d client window is present. So if it is possible to get rid of argb visuals for systray that would solve the present issue. Although, even if that is possible, I'd probably still suggest to do what this MR does, as the logic which guarantees that we never end up blitting from a going-away surface to argb visual never happens with layered windows looks very convoluted and relying on that seems flaky; that can maybe also change if we'll be improving support for layered windows in some way.