[gnome-control-center] display: Round the displayed scale values logically



commit 23d5ea29aa1dc2bd7e4bda0f71382529113d0430
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Aug 28 18:37:22 2017 +0200

    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

 panels/display/cc-display-panel.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 277c39d..32e5102 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -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 *
 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);
   g_free (text);
   return label;


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