wayland: Send presentation feedbacks to cursors

This commit assumes that cursor surfaces work in a "mailbox" fashion. If
they are painted multiple times before a successful flip, all commits
but the last get discarded, and the last commit gets presented after the
flip succeeds. This is more or less how it works in the atomic backend,
and also more or less how it works in other backends, with the exception
that the cursor painting might fail without any way of knowing. This
assumption is still better than unconditionally discarding all cursor
surface feedbacks as if the cursor painting always fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
This commit is contained in:
Ivan Molodetskikh
2021-02-02 16:51:34 +03:00
committed by Marge Bot
parent cd9ae13465
commit 82af1fb87e
3 changed files with 69 additions and 9 deletions

View File

@ -30,6 +30,7 @@
#include "core/boxes-private.h"
#include "wayland/meta-cursor-sprite-wayland.h"
#include "wayland/meta-wayland-buffer.h"
#include "wayland/meta-wayland-presentation-time-private.h"
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-xwayland.h"
@ -340,6 +341,9 @@ on_cursor_painted (MetaCursorRenderer *renderer,
MetaWaylandCursorSurfacePrivate *priv =
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
guint32 time = (guint32) (g_get_monotonic_time () / 1000);
MetaBackend *backend = meta_get_backend ();
MetaWaylandCompositor *compositor =
meta_backend_get_wayland_compositor (backend);
if (displayed_sprite != META_CURSOR_SPRITE (priv->cursor_sprite))
return;
@ -352,6 +356,10 @@ on_cursor_painted (MetaCursorRenderer *renderer,
wl_callback_send_done (callback->resource, time);
wl_resource_destroy (callback->resource);
}
meta_wayland_presentation_time_cursor_painted (&compositor->presentation_time,
stage_view,
cursor_surface);
}
void