From 6895e1700f78735bda8cdf5156e05954f44907e0 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 25 Jan 2023 21:59:21 -0500
Subject: [PATCH] video: Ensure that the closest returned video mode match
always has a valid scale value
---
src/video/SDL_video.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index cb8e01ed3e72..01aa23629e84 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1014,7 +1014,13 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di
closest->w = mode->w;
closest->h = mode->h;
}
- closest->display_scale = mode->display_scale;
+ if (match->display_scale > 0.0f) {
+ closest->display_scale = match->display_scale;
+ } else if (mode->display_scale > 0.0f) {
+ closest->display_scale = mode->display_scale;
+ } else {
+ closest->display_scale = 1.0f;
+ }
if (match->refresh_rate > 0.0f) {
closest->refresh_rate = match->refresh_rate;