From c4d7265656c4cb7215f3355896018daa693f97c4 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Mon, 14 Aug 2023 18:21:44 +0800 Subject: [PATCH] kms/cursor-manager: Transform cursor movement from view space to CRTC Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2955, https://gitlab.gnome.org/GNOME/mutter/-/issues/2957 Part-of: --- src/backends/native/meta-kms-cursor-manager.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/backends/native/meta-kms-cursor-manager.c b/src/backends/native/meta-kms-cursor-manager.c index 3bcf9dc34..418022c39 100644 --- a/src/backends/native/meta-kms-cursor-manager.c +++ b/src/backends/native/meta-kms-cursor-manager.c @@ -263,12 +263,20 @@ calculate_cursor_rect (CrtcStateImpl *crtc_state_impl, float y, graphene_rect_t *out_cursor_rect) { - float crtc_x, crtc_y; + int crtc_x, crtc_y, crtc_width, crtc_height; int buffer_width, buffer_height; graphene_rect_t cursor_rect; crtc_x = (x - crtc_state_impl->layout.origin.x) * crtc_state_impl->scale; crtc_y = (y - crtc_state_impl->layout.origin.y) * crtc_state_impl->scale; + crtc_width = roundf (crtc_state_impl->layout.size.width * + crtc_state_impl->scale); + crtc_height = roundf (crtc_state_impl->layout.size.height * + crtc_state_impl->scale); + + meta_monitor_transform_transform_point (crtc_state_impl->transform, + &crtc_width, &crtc_height, + &crtc_x, &crtc_y); buffer_width = meta_drm_buffer_get_width (buffer); buffer_height = meta_drm_buffer_get_height (buffer); @@ -285,10 +293,8 @@ calculate_cursor_rect (CrtcStateImpl *crtc_state_impl, }; if (cursor_rect.origin.x + cursor_rect.size.width > 0.0 && cursor_rect.origin.y + cursor_rect.size.height > 0.0 && - cursor_rect.origin.x < (crtc_state_impl->layout.size.width * - crtc_state_impl->scale) && - cursor_rect.origin.y < (crtc_state_impl->layout.size.height * - crtc_state_impl->scale)) + cursor_rect.origin.x < crtc_width && + cursor_rect.origin.y < crtc_height) { if (out_cursor_rect) *out_cursor_rect = cursor_rect;