Merge branch 'fix-window-icon' into 'master'

Fix window icon being reset when switching renderers on non-Windows platforms

See merge request STJr/SRB2!898
This commit is contained in:
MascaraSnake 2020-05-13 04:14:51 -04:00
commit 9d06cb4be4

View file

@ -217,7 +217,6 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool
else else
{ {
Impl_CreateWindow(fullscreen); Impl_CreateWindow(fullscreen);
Impl_SetWindowIcon();
wasfullscreen = fullscreen; wasfullscreen = fullscreen;
SDL_SetWindowSize(window, width, height); SDL_SetWindowSize(window, width, height);
if (fullscreen) if (fullscreen)
@ -1632,12 +1631,15 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
window = SDL_CreateWindow("SRB2 "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window = SDL_CreateWindow("SRB2 "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
realwidth, realheight, flags); realwidth, realheight, flags);
if (window == NULL) if (window == NULL)
{ {
CONS_Printf(M_GetText("Couldn't create window: %s\n"), SDL_GetError()); CONS_Printf(M_GetText("Couldn't create window: %s\n"), SDL_GetError());
return SDL_FALSE; return SDL_FALSE;
} }
Impl_SetWindowIcon();
return Impl_CreateContext(); return Impl_CreateContext();
} }
@ -1654,11 +1656,7 @@ static void Impl_SetWindowName(const char *title)
static void Impl_SetWindowIcon(void) static void Impl_SetWindowIcon(void)
{ {
if (window == NULL || icoSurface == NULL) if (window && icoSurface)
{
return;
}
//SDL2STUB(); // Monster Iestyn: why is this stubbed?
SDL_SetWindowIcon(window, icoSurface); SDL_SetWindowIcon(window, icoSurface);
} }
@ -1766,6 +1764,11 @@ void I_StartupGraphics(void)
VID_StartupOpenGL(); VID_StartupOpenGL();
#endif #endif
// Window icon
#ifdef HAVE_IMAGE
icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm);
#endif
// Fury: we do window initialization after GL setup to allow // Fury: we do window initialization after GL setup to allow
// SDL_GL_LoadLibrary to work well on Windows // SDL_GL_LoadLibrary to work well on Windows
@ -1784,11 +1787,6 @@ void I_StartupGraphics(void)
#ifdef HAVE_TTF #ifdef HAVE_TTF
I_ShutdownTTF(); I_ShutdownTTF();
#endif #endif
// Window icon
#ifdef HAVE_IMAGE
icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm);
#endif
Impl_SetWindowIcon();
VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT)); VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT));