drm/backend: add support for cursor hotspots

Enables DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT and sets the cursor hotspots on the
cursor plane so virtualized drivers can accelerate mouse movement.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3776
This commit is contained in:
Ian Forbes 2024-03-19 16:20:32 -05:00
parent 94c31b824c
commit e3bd318547
4 changed files with 20 additions and 1 deletions

View file

@ -353,6 +353,10 @@ static void set_plane_props(struct atomic *atom, struct wlr_drm_backend *drm,
atomic_add(atom, id, props->crtc_y, (uint64_t)y);
}
static bool supports_cursor_hotspots(const struct wlr_drm_plane* plane) {
return plane->props.hotspot_x && plane->props.hotspot_y;
}
static void atomic_connector_add(struct atomic *atom,
const struct wlr_drm_connector_state *state, bool modeset) {
struct wlr_drm_connector *conn = state->connector;
@ -391,6 +395,12 @@ static void atomic_connector_add(struct atomic *atom,
if (drm_connector_is_cursor_visible(conn)) {
set_plane_props(atom, drm, crtc->cursor, state->cursor_fb,
crtc->id, conn->cursor_x, conn->cursor_y);
if (supports_cursor_hotspots(crtc->cursor)) {
atomic_add(atom, crtc->cursor->id,
crtc->cursor->props.hotspot_x, conn->cursor_hotspot_x);
atomic_add(atom, crtc->cursor->id,
crtc->cursor->props.hotspot_y, conn->cursor_hotspot_y);
}
} else {
plane_disable(atom, crtc->cursor);
}