Sdl12-compat: Rebuild window in SDL_SetVideoMode when size changes

From e3bf3c6d2f1749ce184ed8ab6e0526d3d931b818 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 21 Feb 2021 00:05:50 +0300
Subject: [PATCH] Rebuild window in SDL_SetVideoMode when size changes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Patch from Darío Cutillas:
https://github.com/libsdl-org/sdl12-compat/issues/12
---
 src/SDL12_compat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index f9bacab..6db6ad3 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -2852,6 +2852,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
         EndVidModeCreate();  /* rebuild the window if moving to/from a GL context */
     } else if ( VideoSurface12 && (VideoSurface12->surface20->format->format != appfmt)) {
         EndVidModeCreate();  /* rebuild the window if changing pixel format */
+    } else if ( VideoSurface12 && (VideoSurface12->w != width || VideoSurface12->h != height) && ((flags12 & SDL12_FULLSCREEN) == 0)) {
+        EndVidModeCreate(); /* rebuild the window if window size changed and not in full screen */
     } else if (VideoGLContext20) {
         /* SDL 1.2 (infuriatingly!) destroys the GL context on each resize, so we will too */
         SDL20_GL_MakeCurrent(NULL, NULL);