[mutter] clutter/text: Scale down clutter_text_get_cursor_rect to actor coordinates



commit db30a4d7b41fe5a016052b2b73fed5aa81c27280
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Thu Nov 19 18:09:27 2020 +0800

    clutter/text: Scale down clutter_text_get_cursor_rect to actor coordinates
    
    `priv->cursor_rect` is stored in physical pixels, not local coordinates.
    So unscale it before returning from `clutter_text_get_cursor_rect`, which
    is explicitly documented as returning "actor-relative coordinates".
    
    This went missed with fractional scaling support, and unnoticed as nobody
    uses `clutter_text_get_cursor_rect` yet. But that will soon change.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1576>

 clutter/clutter/clutter-text.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 4967b02588..98fa0772a8 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -6793,10 +6793,17 @@ void
 clutter_text_get_cursor_rect (ClutterText     *self,
                               graphene_rect_t *rect)
 {
+  float inverse_scale;
+
   g_return_if_fail (CLUTTER_IS_TEXT (self));
   g_return_if_fail (rect != NULL);
 
-  *rect = self->priv->cursor_rect;
+  inverse_scale = 1.f / clutter_actor_get_resource_scale (CLUTTER_ACTOR (self));
+
+  graphene_rect_scale (&self->priv->cursor_rect,
+                       inverse_scale,
+                       inverse_scale,
+                       rect);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]