diff options
Diffstat (limited to 'src/backends/meta-monitor.c')
-rw-r--r-- | src/backends/meta-monitor.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index 41f30eeb3..d4fb3c0bd 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -1737,6 +1737,18 @@ is_logical_size_large_enough (int width, return width * height >= MINIMUM_LOGICAL_AREA; } +static gboolean +is_scale_valid_for_size (float width, + float height, + float scale) +{ + if (scale < MINIMUM_SCALE_FACTOR || scale > MAXIMUM_SCALE_FACTOR) + return FALSE; + + return is_logical_size_large_enough (floorf (width / scale), + floorf (height / scale)); +} + gboolean meta_monitor_mode_should_be_advertised (MetaMonitorMode *monitor_mode) { @@ -1766,20 +1778,16 @@ get_closest_scale_factor_for_resolution (float width, gboolean found_one; best_scale = 0; - scaled_w = width / scale; - scaled_h = height / scale; - if (scale < MINIMUM_SCALE_FACTOR || - scale > MAXIMUM_SCALE_FACTOR || - !is_logical_size_large_enough (floorf (scaled_w), floorf (scaled_h))) + if (!is_scale_valid_for_size (width, height, scale)) goto out; - if (floorf (scaled_w) == scaled_w && floorf (scaled_h) == scaled_h) + if (fmodf (width, scale) == 0.0 && fmodf (height, scale) == 0.0) return scale; i = 0; found_one = FALSE; - base_scaled_w = floorf (scaled_w); + base_scaled_w = floorf (width / scale); do { @@ -1840,15 +1848,20 @@ meta_monitor_calculate_supported_scales (MetaMonitor *monitor, float scale; float scale_value = i + j * SCALE_FACTORS_STEPS; - if ((constraints & META_MONITOR_SCALES_CONSTRAINT_NO_FRAC) && - fmodf (scale_value, 1.0) != 0.0) + if (constraints & META_MONITOR_SCALES_CONSTRAINT_NO_FRAC) { - continue; - } + if (fmodf (scale_value, 1.0) != 0.0 || + !is_scale_valid_for_size (width, height, scale_value)) + continue; - scale = get_closest_scale_factor_for_resolution (width, - height, - scale_value); + scale = scale_value; + } + else + { + scale = get_closest_scale_factor_for_resolution (width, + height, + scale_value); + } if (scale > 0.0f) g_array_append_val (supported_scales, scale); |