display: Round the displayed scale values logically

Mutter currently generates 4 scales per integer scale. Knowing that,
we can nicely "round" the values we display to what the ideal scales
are even though the real values might be skewed since mutter creates
scale values close to the ideal ones that yield integer logical sizes.

https://bugzilla.gnome.org/show_bug.cgi?id=786922
This commit is contained in:
Rui Matos 2017-08-28 18:37:22 +02:00
parent bbccf27488
commit 23d5ea29aa

View file

@ -1105,10 +1105,17 @@ scale_buttons_active (CcDisplayPanel *panel,
} }
} }
static double
round_scale_for_ui (double scale)
{
/* Keep in sync with mutter */
return round (scale*4)/4;
}
static GtkWidget * static GtkWidget *
make_label_for_scale (double scale) make_label_for_scale (double scale)
{ {
gchar *text = g_strdup_printf (" %d%% ", (int) round (scale*100)); gchar *text = g_strdup_printf (" %d %% ", (int) (round_scale_for_ui (scale)*100));
GtkWidget *label = gtk_label_new (text); GtkWidget *label = gtk_label_new (text);
g_free (text); g_free (text);
return label; return label;