Commit 2077e906 authored by Benjamin Berg's avatar Benjamin Berg

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

See mutter#412

(cherry picked from commit 4db431d7)
parent 302af255
Pipeline #53363 passed with stages
in 7 minutes and 19 seconds
......@@ -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);
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment