monitor: Don't use locale dependent mode ID string

The result of printf("%f", number) depends on the locale. To avoid
unpredictable mode IDs, make sure they always are generated the same no
matter the locale.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2902>
This commit is contained in:
Jonas Ådahl 2023-03-07 00:17:25 +01:00 committed by Marge Bot
parent 429cc9a674
commit 550a1dadf1

View File

@ -613,14 +613,17 @@ static char *
generate_mode_id (MetaMonitorModeSpec *monitor_mode_spec)
{
gboolean is_interlaced;
char rate_str[G_ASCII_DTOSTR_BUF_SIZE];
is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE);
g_ascii_formatd (rate_str, sizeof (rate_str),
"%.3f", monitor_mode_spec->refresh_rate);
return g_strdup_printf ("%dx%d%s@%.3f",
return g_strdup_printf ("%dx%d%s@%s",
monitor_mode_spec->width,
monitor_mode_spec->height,
is_interlaced ? "i" : "",
monitor_mode_spec->refresh_rate);
rate_str);
}
static gboolean