xwayland: Hold window buffer until released
The window buffer mechanism would free the pixmap and its corresponding Wayland buffer as soon as window buffers are disposed. Typically when the X11 window is unrealized, the current window buffer is still used by the Wayland compositor and yet Xwayland will destroy the buffer. As a matter of fact, Xwayland should not destroy the Wayland buffer before the wl_buffer.release event is received. Add a reference counter to the window buffer similar to the to pixmap reference counter to keep the buffer around until the release callback is received. Increase that reference counter on the buffer which will be attached to the surface, and drop that reference when receiving the release callback notification. v2: Use a specific reference counter on the buffer rather than relying on the pixmap refcnt (Michel Dänzer <mdaenzer@redhat.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Acked-by: Martin Peres <martin.peres@mupuf.org>