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>
4 jobs for fix-buffer-release-cb in 4 minutes and 26 seconds (queued for 1 second)
Status Name Job ID Coverage
  Docker Image
passed debian-buster #6097339

00:00:11

 
  Build And Test
passed autotools #6097340

00:04:15

passed meson #6097341

00:01:48

passed meson-noglamor #6097342

00:00:46