Disable the XRandR extension by default, since KDE maximizes windows which are larger than the new resolution, and then doesn't restore their size and positition when the old resolution is restored.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Apr 2006 17:54:32 +0000
changeset 1746a0ddae8b43cf
parent 1745 741dc4e89f3a
child 1747 e75d0cbcf3c8
Disable the XRandR extension by default, since KDE maximizes windows which are larger than the new resolution, and then doesn't restore their size and positition when the old resolution is restored.
The extension can be enabled with the environment variable SDL_VIDEO_X11_XRANDR=1
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Sat Apr 29 04:08:40 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Sat Apr 29 17:54:32 2006 +0000
     1.3 @@ -360,10 +360,109 @@
     1.4  /* Global for the error handler */
     1.5  int vm_event, vm_error = -1;
     1.6  
     1.7 +#if SDL_VIDEO_DRIVER_X11_XRANDR
     1.8 +static int CheckXRandR(_THIS, int *major, int *minor)
     1.9 +{
    1.10 +    char *env;
    1.11 +
    1.12 +    /* Default the extension not available */
    1.13 +    *major = *minor = 0;
    1.14 +
    1.15 +    /* Allow environment override */
    1.16 +    env = getenv("SDL_VIDEO_X11_XRANDR");
    1.17 +    if ( env && !SDL_atoi(env) ) {
    1.18 +        return 0;
    1.19 +    }
    1.20 +
    1.21 +    /* This defaults off now, due to KDE window maximize problems */
    1.22 +    if ( !env ) {
    1.23 +        return 0;
    1.24 +    }
    1.25 +
    1.26 +    if ( !SDL_X11_HAVE_XRANDR ) {
    1.27 +        return 0;
    1.28 +    }
    1.29 +
    1.30 +    /* Query the extension version */
    1.31 +    if ( !XRRQueryVersion(SDL_Display, major, minor) ) {
    1.32 +        return 0;
    1.33 +    }
    1.34 +    return 1;
    1.35 +}
    1.36 +#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
    1.37 +
    1.38 +#if SDL_VIDEO_DRIVER_X11_VIDMODE
    1.39 +static int CheckVidMode(_THIS, int *major, int *minor)
    1.40 +{
    1.41 +    char *env;
    1.42 +
    1.43 +    /* Default the extension not available */
    1.44 +    *major = *minor = 0;
    1.45 +
    1.46 +    /* Allow environment override */
    1.47 +    env = getenv("SDL_VIDEO_X11_VIDMODE");
    1.48 +    if ( env && !SDL_atoi(env) ) {
    1.49 +        return 0;
    1.50 +    }
    1.51 +    
    1.52 +    /* Metro-X 4.3.0 and earlier has a broken implementation of
    1.53 +       XF86VidModeGetAllModeLines() - it hangs the client.
    1.54 +     */
    1.55 +    if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) {
    1.56 +        FILE *metro_fp;
    1.57 +
    1.58 +        metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
    1.59 +        if ( metro_fp != NULL ) {
    1.60 +            int major, minor, patch, version;
    1.61 +            major = 0; minor = 0; patch = 0;
    1.62 +            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
    1.63 +            fclose(metro_fp);
    1.64 +            version = major*100+minor*10+patch;
    1.65 +            if ( version < 431 ) {
    1.66 +                return 0;
    1.67 +            }
    1.68 +        }
    1.69 +    }
    1.70 +
    1.71 +    /* Query the extension version */
    1.72 +    if ( !SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) ||
    1.73 +         !SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, major, minor) ) {
    1.74 +        return 0;
    1.75 +    }
    1.76 +    return 1;
    1.77 +}
    1.78 +#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
    1.79 +
    1.80 +#if SDL_VIDEO_DRIVER_X11_XME
    1.81 +static int CheckXME(_THIS, int *major, int *minor)
    1.82 +{
    1.83 +    char *env;
    1.84 +
    1.85 +    /* Default the extension not available */
    1.86 +    *major = *minor = 0;
    1.87 +
    1.88 +    /* Allow environment override */
    1.89 +    env = getenv("SDL_VIDEO_X11_VIDMODE");
    1.90 +    if ( env && !SDL_atoi(env) ) {
    1.91 +        return 0;
    1.92 +    }
    1.93 +    
    1.94 +    /* Query the extension version */
    1.95 +    if ( !XiGMiscQueryVersion(SDL_Display, major, minor) ) {
    1.96 +        return 0;
    1.97 +    }
    1.98 +    return 1;
    1.99 +}
   1.100 +#endif /* SDL_VIDEO_DRIVER_X11_XME */
   1.101 +
   1.102  int X11_GetVideoModes(_THIS)
   1.103  {
   1.104 +#if SDL_VIDEO_DRIVER_X11_XRANDR
   1.105 +    int xrandr_major, xrandr_minor;
   1.106 +    int nsizes;
   1.107 +    XRRScreenSize *sizes;
   1.108 +#endif
   1.109  #if SDL_VIDEO_DRIVER_X11_VIDMODE
   1.110 -    int buggy_X11;
   1.111      int vm_major, vm_minor;
   1.112      int nmodes;
   1.113      SDL_NAME(XF86VidModeModeInfo) **modes;
   1.114 @@ -373,29 +472,20 @@
   1.115      int ractive, nummodes;
   1.116      XiGMiscResolutionInfo *modelist;
   1.117  #endif
   1.118 -#if SDL_VIDEO_DRIVER_X11_XRANDR
   1.119 -    int xrandr_major, xrandr_minor;
   1.120 -    int nsizes;
   1.121 -    XRRScreenSize *sizes;
   1.122 -#endif
   1.123      int i, n;
   1.124      int screen_w;
   1.125      int screen_h;
   1.126  
   1.127 -    vm_error = -1;
   1.128      use_vidmode = 0;
   1.129      use_xrandr = 0;
   1.130      screen_w = DisplayWidth(SDL_Display, SDL_Screen);
   1.131      screen_h = DisplayHeight(SDL_Display, SDL_Screen);
   1.132  
   1.133 +#if SDL_VIDEO_DRIVER_X11_XRANDR
   1.134      /* XRandR */
   1.135 -#if SDL_VIDEO_DRIVER_X11_XRANDR
   1.136      /* require at least XRandR v1.0 (arbitrary) */
   1.137 -    if ( ( SDL_X11_HAVE_XRANDR ) &&
   1.138 -         ( getenv("SDL_VIDEO_X11_NO_XRANDR") == NULL ) &&
   1.139 -         ( XRRQueryVersion(SDL_Display, &xrandr_major, &xrandr_minor) ) &&
   1.140 -         ( xrandr_major >= 1 ) ) {
   1.141 -
   1.142 +    if ( CheckXRandR(this, &xrandr_major, &xrandr_minor) && (xrandr_major >= 1) )
   1.143 +    {
   1.144  #ifdef XRANDR_DEBUG
   1.145          fprintf(stderr, "XRANDR: XRRQueryVersion: V%d.%d\n",
   1.146                  xrandr_major, xrandr_minor);
   1.147 @@ -437,55 +527,10 @@
   1.148  #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
   1.149  
   1.150  #if SDL_VIDEO_DRIVER_X11_VIDMODE
   1.151 -    /* Metro-X 4.3.0 and earlier has a broken implementation of
   1.152 -       XF86VidModeGetAllModeLines() - it hangs the client.
   1.153 -     */
   1.154 -    buggy_X11 = 0;
   1.155 -    if ( SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) {
   1.156 -        FILE *metro_fp;
   1.157 -
   1.158 -        metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
   1.159 -        if ( metro_fp != NULL ) {
   1.160 -            int major, minor, patch, version;
   1.161 -            major = 0; minor = 0; patch = 0;
   1.162 -            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
   1.163 -            version = major*100+minor*10+patch;
   1.164 -            if ( version < 431 ) {
   1.165 -                buggy_X11 = 1;
   1.166 -            }
   1.167 -            fclose(metro_fp);
   1.168 -        }
   1.169 -    }
   1.170 -#if 0 /* Let's try this again... hopefully X servers have improved... */
   1.171 -#if defined(__alpha__) || defined(__sparc64__) || defined(__powerpc__)
   1.172 -    /* The alpha, sparc64 and PPC XFree86 servers are also buggy */
   1.173 -    buggy_X11 = 1;
   1.174 -#endif
   1.175 -#endif
   1.176 -    /* Enumerate the available fullscreen modes */
   1.177 -    if ( ! buggy_X11 ) {
   1.178 -        if ( SDL_NAME(XF86VidModeQueryExtension)(SDL_Display, &vm_event, &vm_error) &&
   1.179 -              SDL_NAME(XF86VidModeQueryVersion)(SDL_Display, &vm_major, &vm_minor) ) {
   1.180 -#ifdef BROKEN_XFREE86_4001
   1.181 -#ifdef X_XF86VidModeGetDotClocks  /* Compiled under XFree86 4.0 */
   1.182 -                /* Earlier X servers hang when doing vidmode */
   1.183 -                if ( vm_major < 2 ) {
   1.184 -#ifdef XFREE86_DEBUG
   1.185 -                    printf("Compiled under XFree86 4.0, server is XFree86 3.X\n");
   1.186 -#endif
   1.187 -                    buggy_X11 = 1;
   1.188 -                }
   1.189 -#else
   1.190 -                /* XFree86 3.X code works with XFree86 4.0 servers */;
   1.191 -#endif /* XFree86 4.0 */
   1.192 -#endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */
   1.193 -        } else {
   1.194 -            buggy_X11 = 1;
   1.195 -        }
   1.196 -    }
   1.197 -    if ( ! buggy_X11 && ! use_xrandr &&
   1.198 -         SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) {
   1.199 -
   1.200 +    /* XVidMode */
   1.201 +    if ( !use_xrandr && CheckVidMode(this, &vm_major, &vm_minor) &&
   1.202 +         SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) )
   1.203 +    {
   1.204  #ifdef XFREE86_DEBUG
   1.205          printf("Available modes: (sorted)\n");
   1.206          for ( i = 0; i < nmodes; ++i ) {
   1.207 @@ -548,36 +593,14 @@
   1.208      }
   1.209  #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
   1.210  
   1.211 -                                /* XiG */
   1.212  #if SDL_VIDEO_DRIVER_X11_XME
   1.213 +    /* XiG */
   1.214 +    modelist = NULL;
   1.215      /* first lets make sure we have the extension, and it's at least v2.0 */
   1.216 -    if (XiGMiscQueryVersion(SDL_Display, &xme_major, &xme_minor)) {
   1.217 -#ifdef XIG_DEBUG
   1.218 -        fprintf(stderr, "XME: XiGMiscQueryVersion: V%d.%d\n",
   1.219 -                xme_major, xme_minor);
   1.220 -#endif
   1.221 -        /* work around a XiGMisc bogosity in our version of libXext */
   1.222 -        if (xme_major == 0 && xme_major == 0) {
   1.223 -            /* Ideally libxme would spit this out, but the problem is that
   1.224 -               the right Query func will never be called if using the bogus
   1.225 -               libXext version.
   1.226 -             */
   1.227 -            fprintf(stderr, 
   1.228 -"XME: If you are using Xi Graphics CDE and a Summit server, you need to\n"
   1.229 -"XME: get the libXext update from Xi's ftp site before fullscreen switching\n"
   1.230 -"XME: will work.  Fullscreen switching is only supported on Summit Servers\n");
   1.231 -          }
   1.232 -    } else {
   1.233 -        /* not there. Bummer. */
   1.234 -        xme_major = xme_minor = 0;
   1.235 -    }
   1.236 -
   1.237 -    modelist = NULL;
   1.238 -    if (xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, 
   1.239 -                                            SDL_Screen,
   1.240 -                                            0, /* view */
   1.241 -                                            &ractive, 
   1.242 -                                            &modelist)) > 1)
   1.243 +    if ( CheckXME(this, &xme_major, &xme_minor) && xme_major >= 2 &&
   1.244 +         (nummodes = XiGMiscQueryResolutions(SDL_Display, SDL_Screen,
   1.245 +                                             0, /* view */
   1.246 +                                             &ractive, &modelist)) > 1 )
   1.247      {                                /* then we actually have some */
   1.248          int j;
   1.249  
   1.250 @@ -683,6 +706,10 @@
   1.251      }
   1.252  
   1.253  #if defined(XFREE86_DEBUG) || defined(XIG_DEBUG)
   1.254 +    if ( use_xrandr ) {
   1.255 +        printf("XRandR is enabled\n");
   1.256 +    }
   1.257 +
   1.258      if ( use_vidmode ) {
   1.259          printf("XFree86 VidMode is enabled\n");
   1.260      }