From 565e95ac4e4cd76e4b24afbbabf5054c85377438 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 6 Jul 2023 18:14:27 -0700 Subject: [PATCH] Fix windows created with SDL_WINDOW_MINIMIZED having inconsistent SDL_WINDOW_HIDDEN flag on Windows - Windows created minimized are shown with SW_SHOWMINNOACTIVE which does not send WM_SHOWWINDOW leaving the window visible (but minimized) on desktop but still with the SDL_WINDOW_HIDDEN flag set. Now the hidden flag is cleared in this case but noted that this means it's not currently possible to create a window that is initially hidden that then is minimized once shown. --- src/video/windows/SDL_windowswindow.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index c200359e4f..bdd3d92a2a 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -567,6 +567,11 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); if (window->flags & SDL_WINDOW_MINIMIZED) { + /* TODO: We have to clear SDL_WINDOW_HIDDEN here to ensure the window flags match the window state. The + window is already shown after this and windows with WS_MINIMIZE do not generate a WM_SHOWWINDOW. This + means you can't currently create a window that is initially hidden and is minimized when shown. + */ + window->flags &= ~SDL_WINDOW_HIDDEN; ShowWindow(hwnd, SW_SHOWMINNOACTIVE); }