[gnome-control-center/gnome-3-30] display: Correctly round scaled monitor size



commit 2077e9066b9f73715628f37d609faef4fab5d2e9
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Jan 14 15:26:55 2019 +0100

    display: Correctly round scaled monitor size
    
    We were converting the floating point numbers to integers using a cast,
    which causes them to be always rounded down. The result is that a
    monitor may be too small by a pixel, creating broken configurations.
    
    Also fix the same issue when calculating whether a scale should be
    supported.
    
    See https://gitlab.gnome.org/GNOME/mutter/issues/412
    
    (cherry picked from commit 4db431d7f128100c45d3df6162a70069bfdb3b74)

 panels/display/cc-display-arrangement.c | 4 ++--
 panels/display/cc-display-panel.c       | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c
index c345ab4e3..630c72e8d 100644
--- a/panels/display/cc-display-arrangement.c
+++ b/panels/display/cc-display-arrangement.c
@@ -117,8 +117,8 @@ get_scaled_geometry (CcDisplayConfig  *config,
   if (cc_display_config_is_layout_logical (config))
     {
       double scale = cc_display_monitor_get_scale (output);
-      *w /= scale;
-      *h /= scale;
+      *w = round (*w / scale);
+      *h = round (*h / scale);
     }
 
   apply_rotation_to_geometry (output, w, h);
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index e5c54f1b3..f4716f70f 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -609,11 +609,15 @@ make_orientation_row (CcDisplayPanel *panel, CcDisplayMonitor *output)
 static gboolean
 display_mode_supported_at_scale (CcDisplayMode *mode, double scale)
 {
-  int width, height;
+  gint width, height;
+  gint scaled_width, scaled_height;
 
   cc_display_mode_get_resolution (mode, &width, &height);
 
-  return width / scale >= MINIMUM_WIDTH && height / scale >= MINIMUM_HEIGHT;
+  scaled_width = round (width / scale);
+  scaled_height = round (height / scale);
+
+  return scaled_width >= MINIMUM_WIDTH && scaled_height >= MINIMUM_HEIGHT;
 }
 
 static void


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