mirror of
https://github.com/brl/mutter.git
synced 2025-01-27 03:49:03 +00:00
monitor: Use fractional scale result to decide the non-fractional scale
We want to avoid using too high scales too easily, which started to happen 2f1dd049bf ("monitor-manager: Rework default scale factor selection"). Instead of using the closest non-fractional scale, which effectively is what we'd do, only round upwards if we're closer than 0.25 (25%). Since there are some wiggle room for scales to make the logical resolution on the integer pixel grid, make sure to compensate. This compensation is done by adding an extra 0.2 to scale difference. For example the following fractional scales will get these corresponding integer scales: * 1.25 -> 1.0 * 1.5 -> 1.0 * 1.75 -> 2.0 * 2.0 -> 2.0 * 2.50 -> 2.0 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2880>
This commit is contained in:
parent
bf8027ef0d
commit
d03dce4378
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user