sdl12-compat: video: Always process and save off the surface from SDL_WM_SetIcon().

From 639a0e7bd33e3bd8d1ab796ad7592367c258f0f8 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 26 Aug 2022 14:06:33 -0400
Subject: [PATCH] video: Always process and save off the surface from
 SDL_WM_SetIcon().

Previously, if there was already a window, we'd just pass it through to
SDL2's SDL_SetWindowIcon(), but:

- This way if we destroy the window for various reasons (like recreating it
because SDL_SetVideoMode is changing the format, etc), we'll be able to
reset the icon, which we couldn't before.

- Before, there were two paths: one where we process the icon before handing
it to SDL2 and one where we didn't. Notably, before, existing windows would
ignore the mask passed to SDL_WM_SetIcon.

This was probably a lot of explanation for what was an accidental line of
code instead of an intentional but buggy design decision.  :)

Fixes #191.
---
 src/SDL12_compat.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index b1f9ba86..a69d5dc8 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -6635,11 +6635,6 @@ SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
     int bpp;
     int ret;
 
-    if (VideoWindow20) {
-        SDL20_SetWindowIcon(VideoWindow20, icon12->surface20);
-        return;
-    }
-
     /* take the mask and zero out those alpha values. */
     oldmode = SDL_BLENDMODE_NONE;
     if (SDL20_GetSurfaceBlendMode(icon12->surface20, &oldmode) < 0) {
@@ -6662,7 +6657,6 @@ SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
             const int h = icon12->h;
             const int mpitch = (w + 7) / 8;
             Uint32 *ptr = (Uint32 *) icon20->pixels;
-
             int x, y;
 
             SDL_assert(icon20->format->BytesPerPixel == 4);
@@ -6685,6 +6679,10 @@ SDL_WM_SetIcon(SDL12_Surface *icon12, Uint8 *mask)
         SDL20_FreeSurface(VideoIcon20);
         VideoIcon20 = icon20;
     }
+
+    if (VideoWindow20) {
+        SDL20_SetWindowIcon(VideoWindow20, VideoIcon20);
+    }
 }
 
 DECLSPEC int SDLCALL