st/theme-node: Use the node's scale factor

Each node stores the scale factor in place when it was created.
Creating nodes with the same style, but with different scale
factors, yields different nodes.

Use the node's scale factor instead of retrieving the context's
one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176
This commit is contained in:
Georges Basile Stavracas Neto 2020-04-03 18:04:13 -03:00
parent 2721c306af
commit 76811b4ebc

View File

@ -979,9 +979,7 @@ get_length_from_term (StThemeNode *node,
} type = ABSOLUTE;
double multiplier = 1.0;
int scale_factor;
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
if (term->type != TERM_NUMBER)
{
@ -996,7 +994,7 @@ get_length_from_term (StThemeNode *node,
{
case NUM_LENGTH_PX:
type = ABSOLUTE;
multiplier = 1 * scale_factor;
multiplier = 1 * node->scale_factor;
break;
case NUM_LENGTH_PT:
type = POINTS;
@ -1127,14 +1125,10 @@ get_length_from_term_int (StThemeNode *node,
{
double value;
GetFromTermResult result;
int scale_factor;
result = get_length_from_term (node, term, use_parent_font, &value);
if (result == VALUE_FOUND)
{
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
*length = (int) ((value / scale_factor) + 0.5) * scale_factor;
}
*length = (int) ((value / node->scale_factor) + 0.5) * node->scale_factor;
return result;
}
@ -3016,7 +3010,6 @@ StBorderImage *
st_theme_node_get_border_image (StThemeNode *node)
{
int i;
int scale_factor;
if (node->border_image_computed)
return node->border_image;
@ -3025,7 +3018,6 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image_computed = TRUE;
ensure_properties (node);
g_object_get (node->context, "scale-factor", &scale_factor, NULL);
for (i = node->n_properties - 1; i >= 0; i--)
{
@ -3130,7 +3122,7 @@ st_theme_node_get_border_image (StThemeNode *node)
node->border_image = st_border_image_new (file,
border_top, border_right, border_bottom, border_left,
scale_factor);
node->scale_factor);
g_object_unref (file);