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
This commit is contained in:
Florian Müllner 2020-06-16 22:53:37 +02:00
parent e4cbe5126a
commit 3f4b253dac

View File

@ -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 static void
st_viewport_apply_transform (ClutterActor *actor, st_viewport_apply_transform (ClutterActor *actor,
CoglMatrix *matrix) CoglMatrix *matrix)
@ -314,7 +334,7 @@ st_viewport_apply_transform (ClutterActor *actor,
parent_class->apply_transform (actor, matrix); parent_class->apply_transform (actor, matrix);
if (priv->hadjustment) if (priv->hadjustment)
x = st_adjustment_get_value (priv->hadjustment); x = get_hadjustment_value (viewport);
else else
x = 0; x = 0;
@ -336,7 +356,7 @@ get_border_paint_offsets (StViewport *viewport,
StViewportPrivate *priv = st_viewport_get_instance_private (viewport); StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
if (priv->hadjustment) if (priv->hadjustment)
*x = st_adjustment_get_value (priv->hadjustment); *x = get_hadjustment_value (viewport);
else else
*x = 0; *x = 0;