input: Use cursor surface dimensions to evaluate presence of content

When setting a cursor surface, use the surface dimensions, instead of the
weston_surface buffer reference, to check if the surface has any
content. A weston_surface without any buffer reference may in fact
have a buffer which was committed in a previous pointer entry, dropped
by weston_surface and now held only internally by the renderer.

Without this fix, when a pointer enters a surface, the cursor image is
not correctly updated if we set a cursor surface with an already
committed buffer from a previous pointer entry, without recommitting the
cursor buffer for the current entry. This can be seen, for example, in
the experimental Wine Wayland driver which handles the cursor in a way
that leads to the following scenario:

Setup: cursor_surface.attach(buffer) & cursor_surface.commit()
On first wl_pointer.enter: pointer.set_cursor(cursor_surface)
compositor/renderer redraws
wl_pointer.leave
On second wl_pointer.enter: pointer.set_cursor(cursor_surface)

When handling the second pointer.set_cursor() request the current code
doesn't find a buffer attached to the cursor_surface (only the renderer
now has a reference to it), so it doesn't update the respective view for
the cursor.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This commit is contained in:
Alexandros Frantzis 2021-06-09 10:56:26 +03:00
parent 16e3f27fc7
commit 28d66344a0

View File

@ -2749,7 +2749,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
pointer->hotspot_x = x;
pointer->hotspot_y = y;
if (surface->buffer_ref.buffer) {
if (surface->width != 0) {
pointer_cursor_surface_committed(surface, 0, 0);
weston_view_schedule_repaint(pointer->sprite);
}