Fixed bug where Xinerama was treated as being available even if it wasn't.
authorSam Lantinga
Thu, 27 Sep 2012 10:41:16 -0700
changeset 64686af2a8db95d0
parent 6467 ec5a04e921d4
child 6469 ce84310d85ef
Fixed bug where Xinerama was treated as being available even if it wasn't.
Also added additional logging for X11 video modes
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Thu Sep 27 03:36:13 2012 -0400
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Thu Sep 27 10:41:16 2012 -0700
     1.3 @@ -204,7 +204,7 @@
     1.4          mode.refresh_rate = 0;
     1.5          mode.driverdata = NULL;
     1.6  
     1.7 -        displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
     1.8 +        displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata));
     1.9          if (!displaydata) {
    1.10              continue;
    1.11          }
    1.12 @@ -272,10 +272,16 @@
    1.13      /* Allow environment override */
    1.14      env = getenv("SDL_VIDEO_X11_XINERAMA");
    1.15      if (env && !SDL_atoi(env)) {
    1.16 +#ifdef X11MODES_DEBUG
    1.17 +        printf("Xinerama disabled due to environment variable\n");
    1.18 +#endif
    1.19          return SDL_FALSE;
    1.20      }
    1.21  
    1.22      if (!SDL_X11_HAVE_XINERAMA) {
    1.23 +#ifdef X11MODES_DEBUG
    1.24 +        printf("Xinerama support not available\n");
    1.25 +#endif
    1.26          return SDL_FALSE;
    1.27      }
    1.28  
    1.29 @@ -283,8 +289,14 @@
    1.30      if (!XineramaQueryExtension(display, &event_base, &error_base) ||
    1.31          !XineramaQueryVersion(display, major, minor) ||
    1.32          !XineramaIsActive(display)) {
    1.33 +#ifdef X11MODES_DEBUG
    1.34 +        printf("Xinerama not active on the display\n");
    1.35 +#endif
    1.36          return SDL_FALSE;
    1.37      }
    1.38 +#ifdef X11MODES_DEBUG
    1.39 +    printf("Xinerama available!\n");
    1.40 +#endif
    1.41      return SDL_TRUE;
    1.42  }
    1.43  #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
    1.44 @@ -301,17 +313,29 @@
    1.45      /* Allow environment override */
    1.46      env = getenv("SDL_VIDEO_X11_XRANDR");
    1.47      if (env && !SDL_atoi(env)) {
    1.48 +#ifdef X11MODES_DEBUG
    1.49 +        printf("XRandR disabled due to environment variable\n");
    1.50 +#endif
    1.51          return SDL_FALSE;
    1.52      }
    1.53  
    1.54      if (!SDL_X11_HAVE_XRANDR) {
    1.55 +#ifdef X11MODES_DEBUG
    1.56 +        printf("XRandR support not available\n");
    1.57 +#endif
    1.58          return SDL_FALSE;
    1.59      }
    1.60  
    1.61      /* Query the extension version */
    1.62      if (!XRRQueryVersion(display, major, minor)) {
    1.63 +#ifdef X11MODES_DEBUG
    1.64 +        printf("XRandR not active on the display\n");
    1.65 +#endif
    1.66          return SDL_FALSE;
    1.67      }
    1.68 +#ifdef X11MODES_DEBUG
    1.69 +    printf("XRandR available!\n");
    1.70 +#endif
    1.71      return SDL_TRUE;
    1.72  }
    1.73  #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
    1.74 @@ -328,10 +352,16 @@
    1.75      /* Allow environment override */
    1.76      env = getenv("SDL_VIDEO_X11_XVIDMODE");
    1.77      if (env && !SDL_atoi(env)) {
    1.78 +#ifdef X11MODES_DEBUG
    1.79 +        printf("XVidMode disabled due to environment variable\n");
    1.80 +#endif
    1.81          return SDL_FALSE;
    1.82      }
    1.83  
    1.84      if (!SDL_X11_HAVE_XVIDMODE) {
    1.85 +#ifdef X11MODES_DEBUG
    1.86 +        printf("XVidMode support not available\n");
    1.87 +#endif
    1.88          return SDL_FALSE;
    1.89      }
    1.90  
    1.91 @@ -339,8 +369,14 @@
    1.92      vm_error = -1;
    1.93      if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error)
    1.94          || !XF86VidModeQueryVersion(display, major, minor)) {
    1.95 +#ifdef X11MODES_DEBUG
    1.96 +        printf("XVidMode not active on the display\n");
    1.97 +#endif
    1.98          return SDL_FALSE;
    1.99      }
   1.100 +#ifdef X11MODES_DEBUG
   1.101 +    printf("XVidMode available!\n");
   1.102 +#endif
   1.103      return SDL_TRUE;
   1.104  }
   1.105  
   1.106 @@ -437,8 +473,6 @@
   1.107      mode.format = sdl_display->current_mode.format;
   1.108      mode.driverdata = NULL;
   1.109  
   1.110 -    data->use_xrandr = 0;
   1.111 -    data->use_vidmode = 0;
   1.112      screen_w = DisplayWidth(display, data->screen);
   1.113      screen_h = DisplayHeight(display, data->screen);
   1.114