From 3f4b253dacba460ee359bc832dfbbe40022734aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 16 Jun 2020 22:53:37 +0200 Subject: [PATCH] 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 0eb5a22a1..fb1df91d9 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;