diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2020-12-07 14:09:58 +0100 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2020-12-10 13:49:42 +0100 |
commit | 85d8eac4bcf44c077bb82aaae10ae45feb9c4e72 (patch) | |
tree | 76cef2722377e060fd996f61a5fecd504b53a118 /hw/xwayland | |
parent | 79afbd608b7e6abc5d6d0f7e1fb6e460500c7934 (diff) |
xwayland: Hold cursor buffer until released
The cursor code would destroy the buffer as soon as the cursor is
unrealized on X11 side.
Yet, the Wayland compositor may still be using the buffer as long as a
released callback has not been received.
Increase the reference counter on the pixmap to hold a reference on the
pixmap when attaching it to the surface and use the new pixmap release
callback mechanism to release that reference when the buffer is
released.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Diffstat (limited to 'hw/xwayland')
-rw-r--r-- | hw/xwayland/xwayland-cursor.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c index 6869222b4..91cc18464 100644 --- a/hw/xwayland/xwayland-cursor.c +++ b/hw/xwayland/xwayland-cursor.c @@ -34,6 +34,7 @@ #include "xwayland-cursor.h" #include "xwayland-input.h" +#include "xwayland-pixmap.h" #include "xwayland-screen.h" #include "xwayland-shm.h" #include "xwayland-types.h" @@ -136,6 +137,13 @@ static const struct wl_callback_listener frame_listener = { }; static void +xwl_cursor_buffer_release_callback(void *data) +{ + /* drop the reference we took in set_cursor */ + xwl_shm_destroy_pixmap(data); +} + +static void xwl_cursor_copy_bits_to_pixmap(CursorPtr cursor, PixmapPtr pixmap) { int stride; @@ -161,6 +169,12 @@ xwl_cursor_attach_pixmap(struct xwl_seat *xwl_seat, xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface); wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor); + /* Hold a reference on the pixmap until it's released by the compositor */ + pixmap->refcnt++; + xwl_pixmap_set_buffer_release_cb(pixmap, + xwl_cursor_buffer_release_callback, + pixmap); + wl_surface_commit(xwl_cursor->surface); } |