diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 9ecacb98c..289d0c620 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -1839,6 +1839,7 @@ calculate_scale (MetaMonitor *monitor, int n_scales; float best_scale, best_dpi; int target_dpi; + const float scale_epsilon = 0.2; /* * Somebody encoded the aspect ratio (16/9 or 16/10) instead of the physical @@ -1863,7 +1864,8 @@ calculate_scale (MetaMonitor *monitor, /* We'll only be considering the supported scale factors */ scales = meta_monitor_calculate_supported_scales (monitor, monitor_mode, - constraints, &n_scales); + META_MONITOR_SCALES_CONSTRAINT_NONE, + &n_scales); best_scale = scales[0]; for (int i = 0; i < n_scales; i++) { @@ -1894,6 +1896,12 @@ calculate_scale (MetaMonitor *monitor, } } + if (constraints & META_MONITOR_SCALES_CONSTRAINT_NO_FRAC) + { + best_scale = floorf (MIN (scales[n_scales - 1], + best_scale + 0.25 + scale_epsilon)); + } + return best_scale; } diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index 8fbeeec9c..ffeafe1ef 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -9284,7 +9284,7 @@ meta_test_monitor_calculate_mode_scale (void) .width_mm = 303, /* 3:2 @ 14.34" */ .height_mm = 202, .exp = 1.5, - .exp_nofrac = 2.0, + .exp_nofrac = 1.0, }, { .name = "Generic 23\" 1080p", @@ -9311,7 +9311,7 @@ meta_test_monitor_calculate_mode_scale (void) .width_mm = 598, .height_mm = 336, .exp = 1.5, - .exp_nofrac = 2.0, + .exp_nofrac = 1.0, }, { .name = "Generic 32\" 4K",