monitor: Ensure the preferred mode is always included

If there are two display modes present with the same flags,
and one of them is the preferred mode, it could have been
excluded from the resulting list of display modes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3061>
This commit is contained in:
Timotej Šulík 2023-06-12 00:06:34 +02:00 committed by Marge Bot
parent bea2fdc12b
commit 97f0e2e691

View File

@ -781,7 +781,10 @@ meta_monitor_normal_generate_modes (MetaMonitorNormal *monitor_normal)
* otherwise take the first one in the list. This guarantees that the
* preferred mode is always added.
*/
replace = crtc_mode_info->flags == preferred_mode_flags;
replace = (crtc_mode_info->flags == preferred_mode_flags &&
(!monitor_priv->preferred_mode ||
g_strcmp0 (meta_monitor_mode_get_id (monitor_priv->preferred_mode),
mode->id) != 0));
if (!meta_monitor_add_mode (monitor, mode, replace))
{