diff --git a/src/ConsoleMode/Services/DisplayModeMatch.cs b/src/ConsoleMode/Services/DisplayModeMatch.cs
index bcac80b..fd93108 100644
--- a/src/ConsoleMode/Services/DisplayModeMatch.cs
+++ b/src/ConsoleMode/Services/DisplayModeMatch.cs
@@ -4,15 +4,16 @@ namespace ConsoleMode.Services;
/// Whether the mode a screen is in is the one asked for. TVs and their drivers run the "60 Hz" of video at
/// 59.94 Hz and list both: asking for 2560x1440@60 can leave the TV at @59 (the owner's LG through NVIDIA did),
/// which is that mode, not a failure. Treating it as one made the session re-apply the mode twice (the TV going
-/// blank each time) and log that it couldn't. Pure, so it's tested.
+/// blank each time) and log that it couldn't. Only that way round: a screen at @60 when @59 was picked is in a
+/// different mode from the list, so that one is still applied. Pure, so it's tested.
///
public static class DisplayModeMatch
{
- /// Same size, and a refresh rate within 1 Hz (59/60, 23/24, 29/30, 119/120, 143/144…); 0 = any.
+ /// Same size, and the rate asked for or the video one just under it (60→59, 24→23, 30→29, 120→119, 144→143); 0 = any.
public static bool IsSame(int wantedWidth, int wantedHeight, int wantedHz, int width, int height, int hz)
{
if (wantedWidth > 0 && width != wantedWidth) return false;
if (wantedHeight > 0 && height != wantedHeight) return false;
- return wantedHz <= 0 || Math.Abs(hz - wantedHz) <= 1;
+ return wantedHz <= 0 || hz == wantedHz || hz == wantedHz - 1;
}
}
diff --git a/tests/ConsoleMode.Tests/DisplayModeMatchTests.cs b/tests/ConsoleMode.Tests/DisplayModeMatchTests.cs
index 2e3e317..9562d1a 100644
--- a/tests/ConsoleMode.Tests/DisplayModeMatchTests.cs
+++ b/tests/ConsoleMode.Tests/DisplayModeMatchTests.cs
@@ -14,6 +14,9 @@ public class DisplayModeMatchTests
// A different rate or size is not the mode asked for.
[InlineData(2560, 1440, 60, 2560, 1440, 50, false)]
[InlineData(1920, 1080, 120, 1920, 1080, 60, false)]
+ // A screen at @60 when @59 was picked (a separate mode in the list) is not there yet.
+ [InlineData(2560, 1440, 59, 2560, 1440, 60, false)]
+ [InlineData(3840, 2160, 23, 3840, 2160, 24, false)]
[InlineData(2560, 1440, 60, 3840, 2160, 60, false)]
[InlineData(2560, 1440, 60, 2560, 1600, 60, false)]
// 0 = any (a mode saved without a rate, or only a rate).