From 7b23cd62ca0c94192b002d16e3f40180734b2567 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 23 Apr 2026 13:23:07 -0700
Subject: [PATCH] Revert "(video) fix SDL_GetClosestFullscreenDisplayMode
aspect ratio & refresh rate picking logic"
This reverts commit 0231ff03dee7ae2400ebdf274627052b32790a04.
This causes SDL to return 1024x768 when asking for a best fit to 640x480 (thanks @AJenbo), so I'm reverting this until we can investigate more.
---
src/video/SDL_video.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index e3c4f66185163..764eee219d0dd 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1416,14 +1416,14 @@ bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h,
if (closest) {
float current_aspect_ratio = (float)mode->w / mode->h;
float closest_aspect_ratio = (float)closest->w / closest->h;
- if (SDL_fabsf(aspect_ratio - closest_aspect_ratio) <= SDL_fabsf(aspect_ratio - current_aspect_ratio)) {
- // The mode we already found has a similar or better aspect ratio match
+ if (SDL_fabsf(aspect_ratio - closest_aspect_ratio) < SDL_fabsf(aspect_ratio - current_aspect_ratio)) {
+ // The mode we already found has a better aspect ratio match
continue;
}
if (mode->w == closest->w && mode->h == closest->h &&
- SDL_fabsf(closest->refresh_rate - refresh_rate) <= SDL_fabsf(mode->refresh_rate - refresh_rate)) {
- /* We already found a mode and the new mode's refresh rate is the same or is further away from our
+ SDL_fabsf(closest->refresh_rate - refresh_rate) < SDL_fabsf(mode->refresh_rate - refresh_rate)) {
+ /* We already found a mode and the new mode is further from our
* refresh rate target */
continue;
}