From 11c82f642504a28587620e91acfbd7dd6ba00bdf Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Tue, 3 Jan 2023 17:09:39 +0000
Subject: [PATCH] Fix resetting OpenGL windows without captions on Windows
---
src/video/wincommon/SDL_syswm.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/video/wincommon/SDL_syswm.c b/src/video/wincommon/SDL_syswm.c
index 3653ebdca..37db98ac1 100644
--- a/src/video/wincommon/SDL_syswm.c
+++ b/src/video/wincommon/SDL_syswm.c
@@ -211,20 +211,22 @@ typedef BOOL (WINAPI *PtrSetWindowTextW)(HWND hWnd, LPCWSTR lpString);
void WIN_SetWMCaption(_THIS, const char *title, const char *icon)
{
+ if (title) {
#ifdef _WIN32_WCE
- /* WinCE uses the UNICODE version */
- LPWSTR lpszW = SDL_iconv_utf8_ucs2((char *)title);
- SetWindowText(SDL_Window, lpszW);
- SDL_free(lpszW);
+ /* WinCE uses the UNICODE version */
+ LPWSTR lpszW = SDL_iconv_utf8_ucs2((char *)title);
+ SetWindowText(SDL_Window, lpszW);
+ SDL_free(lpszW);
#else
- Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
- size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
- char *cvt = SDL_stack_alloc(char, len + 1);
- WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
- SetWindowText(SDL_Window, cvt);
- SDL_stack_free(cvt);
- SDL_free(lpsz);
+ Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
+ size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
+ char *cvt = SDL_stack_alloc(char, len + 1);
+ WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
+ SetWindowText(SDL_Window, cvt);
+ SDL_stack_free(cvt);
+ SDL_free(lpsz);
#endif
+ }
}
int WIN_IconifyWindow(_THIS)