From 7423419db7cb2a6e87c5bd1b0dbfd99fbeb53260 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sun, 25 Dec 2022 23:21:21 -0500
Subject: [PATCH] Fix aspect_fix() to always grow, not shrink. Add additional
 stderr debugging. Don't try to correct the aspect ratio of the window.

---
 src/conio/scale.c   | 6 +++---
 src/conio/sdl_con.c | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/conio/scale.c b/src/conio/scale.c
index 6a9154c594..bde688559a 100644
--- a/src/conio/scale.c
+++ b/src/conio/scale.c
@@ -41,10 +41,10 @@ aspect_fix(int *x, int *y, int aspect_width, int aspect_height)
 	bestx = lround((double)*y * aspect_width / aspect_height);
 	besty = lround((double)*x * aspect_height / aspect_width);
 
-	if (bestx < *x && bestx > 0)
-		*x = bestx;
-	else
+	if (bestx < *x && besty > 0)
 		*y = besty;
+	else
+		*x = bestx;
 }
 
 /*
diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c
index 01fe454956..46b575ec62 100644
--- a/src/conio/sdl_con.c
+++ b/src/conio/sdl_con.c
@@ -604,7 +604,6 @@ static void setup_surfaces_locked(void)
 	aspect_correct(&idealmw, &idealmh, cvstat.aspect_width, cvstat.aspect_height);
 	idealw = cvstat.winwidth;
 	idealh = cvstat.winheight;
-	aspect_fix(&idealw, &idealh, cvstat.aspect_width, cvstat.aspect_height);
 	internal_scaling = window_can_scale_internally(idealw, idealh);
 	sdl.SetHint(SDL_HINT_RENDER_SCALE_QUALITY, internal_scaling ? "0" : "2");
 
@@ -1149,12 +1148,14 @@ void sdl_video_event_thread(void *data)
 										dst.x = (cvstat.winwidth - dst.w) / 2;
 										dst.y = (cvstat.winheight - dst.h) / 2;
 									}
-									sdl.RenderCopy(renderer, texture, &src, &dst);
+									if (sdl.RenderCopy(renderer, texture, &src, &dst))
+										fprintf(stderr, "RenderCopy() failed! (%s)\n", sdl.GetError());
 								}
 								bitmap_drv_free_rect(list);
 							}
 							sdl.RenderPresent(renderer);
 						}
+						
 						pthread_mutex_unlock(&win_mutex);
 						break;
 					case SDL_USEREVENT_SETNAME:
-- 
GitLab