[gnome-shell] st/viewport: Fix horizontal translation in RTL locales



commit 3f4b253dacba460ee359bc832dfbbe40022734aa
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jun 16 22:53:37 2020 +0200

    st/viewport: Fix horizontal translation in RTL locales
    
    In RTL locales, the lowest value should correspond to the right-most
    position and vice-versa.
    
    That this went unnoticed for so long shows how we have avoided horizontal
    scrolling so far :-)
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1318

 src/st/st-viewport.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/st/st-viewport.c b/src/st/st-viewport.c
index 0eb5a22a1e..fb1df91d90 100644
--- a/src/st/st-viewport.c
+++ b/src/st/st-viewport.c
@@ -301,6 +301,26 @@ st_viewport_allocate (ClutterActor           *actor,
     }
 }
 
+static double
+get_hadjustment_value (StViewport *viewport)
+{
+  StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
+  ClutterTextDirection direction;
+  double x, upper, page_size;
+
+  if (!priv->hadjustment)
+    return 0;
+
+  st_adjustment_get_values (priv->hadjustment,
+                            &x, NULL, &upper, NULL, NULL, &page_size);
+
+  direction = clutter_actor_get_text_direction (CLUTTER_ACTOR (viewport));
+  if (direction == CLUTTER_TEXT_DIRECTION_RTL)
+    return upper - page_size - x;
+
+  return x;
+}
+
 static void
 st_viewport_apply_transform (ClutterActor *actor,
                              CoglMatrix   *matrix)
@@ -314,7 +334,7 @@ st_viewport_apply_transform (ClutterActor *actor,
   parent_class->apply_transform (actor, matrix);
 
   if (priv->hadjustment)
-    x = st_adjustment_get_value (priv->hadjustment);
+    x = get_hadjustment_value (viewport);
   else
     x = 0;
 
@@ -336,7 +356,7 @@ get_border_paint_offsets (StViewport *viewport,
   StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
 
   if (priv->hadjustment)
-    *x = st_adjustment_get_value (priv->hadjustment);
+    *x = get_hadjustment_value (viewport);
   else
     *x = 0;
 


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