Merged Ryan's commits
authorSam Lantinga
Fri, 28 Sep 2012 14:22:33 -0700
changeset 650742acda949dfb
parent 6506 305f0fcc0e99
parent 6499 a34024340f54
child 6508 81a3d541d9a2
Merged Ryan's commits
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Fri Sep 28 14:22:18 2012 -0700
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri Sep 28 14:22:33 2012 -0700
     1.3 @@ -150,7 +150,7 @@
     1.4      GL_FBOList *fbo;
     1.5  } GL_TextureData;
     1.6  
     1.7 -static inline const char*
     1.8 +static __inline__ const char*
     1.9  GL_TranslateError (GLenum error)
    1.10  {
    1.11  #define GL_ERROR_TRANSLATE(e) case e: return #e;
    1.12 @@ -190,10 +190,12 @@
    1.13      return ret;
    1.14  }
    1.15  
    1.16 -#if 1
    1.17 +#if 0
    1.18 +#define GL_CheckError(prefix, renderer)
    1.19 +#elif defined(_MSC_VER)
    1.20 +#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __FUNCTION__)
    1.21 +#else
    1.22  #define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, __FILE__, __LINE__, __PRETTY_FUNCTION__)
    1.23 -#else
    1.24 -#define GL_CheckError(prefix, renderer)
    1.25  #endif
    1.26  
    1.27  static int
     2.1 --- a/src/video/x11/SDL_x11video.c	Fri Sep 28 14:22:18 2012 -0700
     2.2 +++ b/src/video/x11/SDL_x11video.c	Fri Sep 28 14:22:33 2012 -0700
     2.3 @@ -116,6 +116,35 @@
     2.4      SDL_X11_UnloadSymbols();
     2.5  }
     2.6  
     2.7 +/* An error handler to reset the vidmode and then call the default handler. */
     2.8 +static SDL_bool safety_net_triggered = SDL_FALSE;
     2.9 +static int (*orig_x11_errhandler) (Display *, XErrorEvent *) = NULL;
    2.10 +static int
    2.11 +X11_SafetyNetErrHandler(Display * d, XErrorEvent * e)
    2.12 +{
    2.13 +    /* if we trigger an error in our error handler, don't try again. */
    2.14 +    if (!safety_net_triggered) {
    2.15 +        safety_net_triggered = SDL_TRUE;
    2.16 +        SDL_VideoDevice *device = SDL_GetVideoDevice();
    2.17 +        if (device != NULL) {
    2.18 +            int i;
    2.19 +            for (i = 0; i < device->num_displays; i++) {
    2.20 +                SDL_VideoDisplay *display = &device->displays[i];
    2.21 +                if (SDL_memcmp(&display->current_mode, &display->desktop_mode,
    2.22 +                               sizeof (SDL_DisplayMode)) != 0) {
    2.23 +                    X11_SetDisplayMode(device, display, &display->desktop_mode);
    2.24 +                }
    2.25 +            }
    2.26 +        }
    2.27 +    }
    2.28 +
    2.29 +    if (orig_x11_errhandler != NULL) {
    2.30 +        return orig_x11_errhandler(d, e);  /* probably terminate. */
    2.31 +    }
    2.32 +
    2.33 +    return 0;
    2.34 +}
    2.35 +
    2.36  static SDL_VideoDevice *
    2.37  X11_CreateDevice(int devindex)
    2.38  {
    2.39 @@ -173,6 +202,10 @@
    2.40      XSynchronize(data->display, True);
    2.41  #endif
    2.42  
    2.43 +    /* Hook up an X11 error handler to recover the desktop resolution. */
    2.44 +    safety_net_triggered = SDL_FALSE;
    2.45 +    orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler);
    2.46 +
    2.47      /* Set the function pointers */
    2.48      device->VideoInit = X11_VideoInit;
    2.49      device->VideoQuit = X11_VideoQuit;