I'm becoming more and more convinced that the application should never use XRandR, and it's the window manager's responsibility to track and manage display modes for fullscreen windows.
authorSam Lantinga <slouken@libsdl.org>
Thu, 04 Oct 2012 13:50:41 -0700
changeset 655890f231aa77b9
parent 6557 87ba88e3f2a9
child 6559 1fc5f5116bd0
I'm becoming more and more convinced that the application should never use XRandR, and it's the window manager's responsibility to track and manage display modes for fullscreen windows.
Because it's so broken, I'm going to disable XRandR by default. You can still enable it via environment variable or application hint (SDL_HINT_VIDEO_X11_XRANDR)
include/SDL_hints.h
src/video/x11/SDL_x11modes.c
     1.1 --- a/include/SDL_hints.h	Thu Oct 04 02:56:25 2012 -0700
     1.2 +++ b/include/SDL_hints.h	Thu Oct 04 13:50:41 2012 -0700
     1.3 @@ -148,7 +148,7 @@
     1.4   *    "0"       - Disable XRandR
     1.5   *    "1"       - Enable XRandR
     1.6   *
     1.7 - *  By default SDL will use XRandR if it is available.
     1.8 + *  By default SDL will not use XRandR because of window manager issues.
     1.9   */
    1.10  #define SDL_HINT_VIDEO_X11_XRANDR           "SDL_VIDEO_X11_XRANDR"
    1.11  
     2.1 --- a/src/video/x11/SDL_x11modes.c	Thu Oct 04 02:56:25 2012 -0700
     2.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Oct 04 13:50:41 2012 -0700
     2.3 @@ -25,7 +25,17 @@
     2.4  #include "SDL_hints.h"
     2.5  #include "SDL_x11video.h"
     2.6  
     2.7 -/*#define X11MODES_DEBUG*/
     2.8 +#define X11MODES_DEBUG
     2.9 +
    2.10 +/* I'm becoming more and more convinced that the application should never use XRandR,
    2.11 + * and it's the window manager's responsibility to track and manage display modes for
    2.12 + * fullscreen windows.  Right now XRandR is completely broken with respect to window
    2.13 + * manager behavior on every window manager that I can find.  For example, on Unity 3D
    2.14 + * if you show a fullscreen window while the resolution is changing (within ~250 ms)
    2.15 + * your window will retain the fullscreen state hint but be decorated and windowed.
    2.16 +*/
    2.17 +#define XRANDR_DISABLED_BY_DEFAULT
    2.18 +
    2.19  
    2.20  static int
    2.21  get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
    2.22 @@ -190,12 +200,21 @@
    2.23  
    2.24      /* Allow environment override */
    2.25      env = SDL_GetHint(SDL_HINT_VIDEO_X11_XRANDR);
    2.26 +#ifdef XRANDR_DISABLED_BY_DEFAULT
    2.27 +    if (!env || !SDL_atoi(env)) {
    2.28 +#ifdef X11MODES_DEBUG
    2.29 +        printf("XRandR disabled by default due to window manager issues\n");
    2.30 +#endif
    2.31 +        return SDL_FALSE;
    2.32 +    }
    2.33 +#else
    2.34      if (env && !SDL_atoi(env)) {
    2.35  #ifdef X11MODES_DEBUG
    2.36          printf("XRandR disabled due to hint\n");
    2.37  #endif
    2.38          return SDL_FALSE;
    2.39      }
    2.40 +#endif /* XRANDR_ENABLED_BY_DEFAULT */
    2.41  
    2.42      if (!SDL_X11_HAVE_XRANDR) {
    2.43  #ifdef X11MODES_DEBUG