From 525842f2e7bb1902250f2ff6c84b42e04511a9c8 Mon Sep 17 00:00:00 2001
From: Anders Jenbo <[EMAIL REDACTED]>
Date: Thu, 23 Apr 2026 23:25:40 +0200
Subject: [PATCH] Prefer higher color depths in
SDL_GetClosestFullscreenDisplayMode()
(cherry picked from commit 9fa9edeadb846722429994a797ce293a30ec684d)
---
src/video/SDL_video.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 0e4eefe19b865..f650f27b7bc3e 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1420,11 +1420,16 @@ bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h,
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 is further from our
- * refresh rate target */
- continue;
+ if (mode->w == closest->w && mode->h == closest->h) {
+ if (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;
+ }
+ if (SDL_BYTESPERPIXEL(closest->format) >= SDL_BYTESPERPIXEL(mode->format)) {
+ // Prefer the highest color depth
+ continue;
+ }
}
}