[gnome-control-center/benzea/display-arrangement-rounding: 3/3] display: Correctly round scaled monitor size



commit 43725a2de14472141b55dd6adae076bcf5d8563b
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

 panels/display/cc-display-arrangement.c | 4 ++--
 panels/display/cc-display-panel.c       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c
index c345ab4e3..b9a23bb12 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 2c6bf85e3..9f8b92eb9 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -631,7 +631,7 @@ display_mode_supported_at_scale (CcDisplayMode *mode, double scale)
 
   cc_display_mode_get_resolution (mode, &width, &height);
 
-  return width / scale >= MINIMUM_WIDTH && height / scale >= MINIMUM_HEIGHT;
+  return round(width / scale) >= MINIMUM_WIDTH && round(height / scale) >= MINIMUM_HEIGHT;
 }
 
 static void


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