mirror of
https://github.com/encounter/SDL.git
synced 2025-12-21 02:39:10 +00:00
Fix creating a minimized window in SDL to not cause focus to be stolen (because ShowWindow( hwnd, SW_MINIMIZE ) would be called after creation, thus changing focus to the prior window based on some per-app list in windows, rather than the window being created with WS_MINIMIZED to start with).
This means we have to consider SDL_WINDOW_MINIMIZED a window creation flag, but on non-windows platforms we just remove it and let the normal FinishWindowCreation re-apply and do the minimize as I have no idea what is right on them or if anything should change. CR: Phil
This commit is contained in:
@@ -97,6 +97,10 @@ GetWindowStyle(SDL_Window * window)
|
||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
style |= STYLE_RESIZABLE;
|
||||
}
|
||||
|
||||
/* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
|
||||
if ( window->flags & SDL_WINDOW_MINIMIZED )
|
||||
style |= WS_MINIMIZE;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
@@ -335,6 +339,9 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
|
||||
if ( window->flags & SDL_WINDOW_MINIMIZED )
|
||||
ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user