Maelstrom: FrameBuf does the right thing with resizable vs non-resizable windows, depending on what the final window size ends up being.

https://github.com/libsdl-org/Maelstrom/commit/39ca15acf73d52394b843bac4e8759da2ebb5ecf

From 39ca15acf73d52394b843bac4e8759da2ebb5ecf Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 22 Sep 2012 23:43:10 -0700
Subject: [PATCH] FrameBuf does the right thing with resizable vs non-resizable
 windows, depending on what the final window size ends up being.

---
 screenlib/SDL_FrameBuf.cpp | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index dbcdb635..25cab402 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -63,31 +63,33 @@ FrameBuf:: Init(int width, int height, Uint32 window_flags, Uint32 render_flags,
 
 	SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
 
-/*
-	texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, width, height);
-	if (!texture) {
-		SetError("Couldn't create target texture: %s", SDL_GetError());
-		return(-1);
-	}
-
-	if (SDL_SetRenderTarget(renderer, texture) < 0) {
-		SetError("Couldn't set render target: %s", SDL_GetError());
-		return(-1);
-	}
-*/
-
 	/* Set the icon, if any */
 	if ( icon ) {
 		SDL_SetWindowIcon(window, icon);
 	}
 
 	/* Set the output area */
-	if ( window_flags & SDL_WINDOW_RESIZABLE ) {
-		int w, h;
+	int w, h;
+	SDL_GetWindowSize(window, &w, &h);
 
-		SDL_GetWindowSize(window, &w, &h);
+	if ( (window_flags & SDL_WINDOW_RESIZABLE) || (w == width && h == height) ) {
 		UpdateWindowSize(w, h);
 	} else {
+		// The application isn't resizable but the window isn't what we
+		// expected, so we'll render to a texture of the expected size
+		// and scale input coordinates accordingly
+
+		texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, width, height);
+		if (!texture) {
+			SetError("Couldn't create target texture: %s", SDL_GetError());
+			return(-1);
+		}
+
+		if (SDL_SetRenderTarget(renderer, texture) < 0) {
+			SetError("Couldn't set render target: %s", SDL_GetError());
+			return(-1);
+		}
+
 		UpdateWindowSize(width, height);
 	}