Skip to content

gdk/vulkancontext: Recreate swapchain when mapping surface

From the first and most important commit:

Right now, we create a VkSurface from either an X11 window, or a
Wayland wl_surface, when creating the GdkVulkanContext from a
GdkSurface.

That works when initially creating it, however, these days, hiding
a GdkSurface may destroy the wl_surface or X window too. Sadly,
GdkVulkanContext doesn't react to that, and keeps using the same
VkSurface that now points to a non-existent object.

Connect to the surface's 'notify::mapped' signal, and either destroy
the VkSurface and VkSwapchain when the surface is unmapped, or
recreate them when the surface is mapped. This ensures the VkSurface
is always pointing to a valid native surface.

Future commits may reorganize how it all fits together, but at the
very least, this commit allows us to use and test the Vulkan renderer
without crashing too often.

One limitation of this MR is that it does not implement fancier surface management nor reorganizes the whole surface / context interaction. I think it's worth having in the mean time, since the crash is too annoying.

Merge request reports