Leave fullscreen mode to pop an assertion dialog
authorSam Lantinga <slouken@libsdl.org>
Wed, 13 Jan 2010 08:44:46 +0000
changeset 3657eaea59cee6f2
parent 3656 f17ea6f49745
child 3658 1a99755b3b04
Leave fullscreen mode to pop an assertion dialog
src/SDL_assert.c
     1.1 --- a/src/SDL_assert.c	Wed Jan 13 08:30:34 2010 +0000
     1.2 +++ b/src/SDL_assert.c	Wed Jan 13 08:44:46 2010 +0000
     1.3 @@ -254,6 +254,8 @@
     1.4  static SDL_assert_state SDL_PromptAssertion(const SDL_assert_data *data)
     1.5  {
     1.6      const char *envr;
     1.7 +    SDL_assert_state state = SDL_ASSERTION_ABORT;
     1.8 +    SDL_WindowID window;
     1.9  
    1.10      debug_print("\n\n"
    1.11                  "Assertion failure at %s (%s:%d), triggered %u time%s:\n"
    1.12 @@ -281,44 +283,62 @@
    1.13          }
    1.14      }
    1.15  
    1.16 +    /* Leave fullscreen mode, if possible (scary!) */
    1.17 +    window = SDL_GetFocusWindow();
    1.18 +    if (window) {
    1.19 +        if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
    1.20 +            SDL_MinimizeWindow(window);
    1.21 +        } else {
    1.22 +            /* No need to mess with the window */
    1.23 +            window = 0;
    1.24 +        }
    1.25 +    }
    1.26 +
    1.27      /* platform-specific UI... */
    1.28  
    1.29  #ifdef _WINDOWS
    1.30 -    return SDL_PromptAssertion_windows(data);
    1.31 +    state = SDL_PromptAssertion_windows(data);
    1.32  
    1.33  #elif __APPLE__
    1.34      /* This has to be done in an Objective-C (*.m) file, so we call out. */
    1.35      extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *);
    1.36 -    return SDL_PromptAssertion_cocoa(data);
    1.37 +    state = SDL_PromptAssertion_cocoa(data);
    1.38  
    1.39 -#elif unix
    1.40 +#else
    1.41      /* this is a little hacky. */
    1.42      for ( ; ; ) {
    1.43          char buf[32];
    1.44          fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
    1.45          fflush(stderr);
    1.46          if (fgets(buf, sizeof (buf), stdin) == NULL) {
    1.47 -            return SDL_ASSERTION_ABORT;
    1.48 +            break;
    1.49          }
    1.50  
    1.51          if (SDL_strcmp(buf, "a") == 0) {
    1.52 -            return SDL_ASSERTION_ABORT;
    1.53 +            state = SDL_ASSERTION_ABORT;
    1.54 +            break;
    1.55          } else if (SDL_strcmp(envr, "b") == 0) {
    1.56 -            return SDL_ASSERTION_BREAK;
    1.57 +            state = SDL_ASSERTION_BREAK;
    1.58 +            break;
    1.59          } else if (SDL_strcmp(envr, "r") == 0) {
    1.60 -            return SDL_ASSERTION_RETRY;
    1.61 +            state = SDL_ASSERTION_RETRY;
    1.62 +            break;
    1.63          } else if (SDL_strcmp(envr, "i") == 0) {
    1.64 -            return SDL_ASSERTION_IGNORE;
    1.65 +            state = SDL_ASSERTION_IGNORE;
    1.66 +            break;
    1.67          } else if (SDL_strcmp(envr, "A") == 0) {
    1.68 -            return SDL_ASSERTION_ALWAYS_IGNORE;
    1.69 +            state = SDL_ASSERTION_ALWAYS_IGNORE;
    1.70 +            break;
    1.71          }
    1.72      }
    1.73 -
    1.74 -#else
    1.75 -    #error Please define your platform or set SDL_ASSERT_LEVEL to 0.
    1.76  #endif
    1.77  
    1.78 -    return SDL_ASSERTION_ABORT;
    1.79 +    /* Re-enter fullscreen mode */
    1.80 +    if (window) {
    1.81 +        SDL_RestoreWindow(window);
    1.82 +    }
    1.83 +
    1.84 +    return state;
    1.85  }
    1.86  
    1.87