Don't minimize fullscreen windows when destroying them. Previously, we'd minimize fullscreen windows (if SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS was set) during SDL_DestroyWindow if they had keyboard focus, because we call SDL_SetKeyboardFocus(NULL) which yields a OnWindowsFocusLost event. Related to https://bugzilla.libsdl.org/show_bug.cgi?id=1840
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index c70beef..aabdffe 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -93,6 +93,8 @@ struct SDL_Window
SDL_Surface *surface;
SDL_bool surface_valid;
+ SDL_bool is_destroying;
+
SDL_WindowShaper *shaper;
SDL_WindowUserData *data;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index a4a8c6e..26e2344 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1288,6 +1288,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
window->next = _this->windows;
+ window->is_destroying = SDL_FALSE;
if (_this->windows) {
_this->windows->prev = window;
@@ -1328,6 +1329,7 @@ SDL_CreateWindowFrom(const void *data)
window->id = _this->next_object_id++;
window->flags = SDL_WINDOW_FOREIGN;
window->last_fullscreen_flags = window->flags;
+ window->is_destroying = SDL_FALSE;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
@@ -1389,6 +1391,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
window->icon = NULL;
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
+ window->is_destroying = SDL_FALSE;
if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateWindow(_this, window) < 0) {
@@ -2169,7 +2172,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
{
const char *hint;
- if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+ if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
return SDL_FALSE;
}
@@ -2228,6 +2231,8 @@ SDL_DestroyWindow(SDL_Window * window)
CHECK_WINDOW_MAGIC(window, );
+ window->is_destroying = SDL_TRUE;
+
/* Restore video mode, etc. */
SDL_HideWindow(window);