Don't minimize fullscreen windows when destroying them.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 15 Jan 2014 11:34:03 -0800
changeset 8112257daea8ac11
parent 8111 426e78ce52e4
child 8113 9fa492281bc9
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
src/video/SDL_sysvideo.h
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_sysvideo.h	Wed Jan 15 11:31:56 2014 -0800
     1.2 +++ b/src/video/SDL_sysvideo.h	Wed Jan 15 11:34:03 2014 -0800
     1.3 @@ -93,6 +93,8 @@
     1.4      SDL_Surface *surface;
     1.5      SDL_bool surface_valid;
     1.6  
     1.7 +    SDL_bool is_destroying;
     1.8 +
     1.9      SDL_WindowShaper *shaper;
    1.10  
    1.11      SDL_WindowUserData *data;
     2.1 --- a/src/video/SDL_video.c	Wed Jan 15 11:31:56 2014 -0800
     2.2 +++ b/src/video/SDL_video.c	Wed Jan 15 11:34:03 2014 -0800
     2.3 @@ -1288,6 +1288,7 @@
     2.4      window->last_fullscreen_flags = window->flags;
     2.5      window->brightness = 1.0f;
     2.6      window->next = _this->windows;
     2.7 +    window->is_destroying = SDL_FALSE;
     2.8  
     2.9      if (_this->windows) {
    2.10          _this->windows->prev = window;
    2.11 @@ -1328,6 +1329,7 @@
    2.12      window->id = _this->next_object_id++;
    2.13      window->flags = SDL_WINDOW_FOREIGN;
    2.14      window->last_fullscreen_flags = window->flags;
    2.15 +    window->is_destroying = SDL_FALSE;
    2.16      window->brightness = 1.0f;
    2.17      window->next = _this->windows;
    2.18      if (_this->windows) {
    2.19 @@ -1389,6 +1391,7 @@
    2.20      window->icon = NULL;
    2.21      window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
    2.22      window->last_fullscreen_flags = window->flags;
    2.23 +    window->is_destroying = SDL_FALSE;
    2.24  
    2.25      if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
    2.26          if (_this->CreateWindow(_this, window) < 0) {
    2.27 @@ -2169,7 +2172,7 @@
    2.28  {
    2.29      const char *hint;
    2.30  
    2.31 -    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    2.32 +    if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) {
    2.33          return SDL_FALSE;
    2.34      }
    2.35  
    2.36 @@ -2228,6 +2231,8 @@
    2.37  
    2.38      CHECK_WINDOW_MAGIC(window, );
    2.39  
    2.40 +    window->is_destroying = SDL_TRUE;
    2.41 +
    2.42      /* Restore video mode, etc. */
    2.43      SDL_HideWindow(window);
    2.44