[gnome-control-center/benzea/display-arrangement-rounding: 9/9] display: Correctly round scaled monitor size
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/benzea/display-arrangement-rounding: 9/9] display: Correctly round scaled monitor size
- Date: Fri, 18 Jan 2019 10:17:26 +0000 (UTC)
commit 9afaed1160728debe8a34cd07aef41b98a586356
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 | 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 2c6bf85e3..e49ff4177 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -627,11 +627,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]