From 743e8cc249168ccc64073ab83c00c31a30ca22e7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 14 Sep 2017 12:42:47 +0200 Subject: [PATCH] backends: Add some wiggle room for refresh rate comparisons We have not enough control over the sources of the refresh rate float variable to make == comparisons reliable, add some room when comparing these. https://bugzilla.gnome.org/show_bug.cgi?id=787668 --- src/backends/meta-monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index e3595fcd1..70350c3e5 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -32,6 +32,7 @@ #define MAXIMUM_SCALE_FACTOR 4.0f #define MINIMUM_LOGICAL_WIDTH 800 #define MINIMUM_LOGICAL_HEIGHT 600 +#define MAXIMUM_REFRESH_RATE_DIFF 0.001 #define HANDLED_CRTC_MODE_FLAGS (META_CRTC_MODE_FLAG_INTERLACE) @@ -1252,8 +1253,8 @@ meta_monitor_mode_spec_equals (MetaMonitorModeSpec *monitor_mode_spec, { return (monitor_mode_spec->width == other_monitor_mode_spec->width && monitor_mode_spec->height == other_monitor_mode_spec->height && - (monitor_mode_spec->refresh_rate == - other_monitor_mode_spec->refresh_rate) && + ABS (monitor_mode_spec->refresh_rate - + other_monitor_mode_spec->refresh_rate) < MAXIMUM_REFRESH_RATE_DIFF && monitor_mode_spec->flags == other_monitor_mode_spec->flags); }