Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug where Xinerama was treated as being available even if it wa…
Browse files Browse the repository at this point in the history
…sn't.

Also added additional logging for X11 video modes
  • Loading branch information
slouken committed Sep 27, 2012
1 parent a51ee16 commit cc4f35c
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions src/video/x11/SDL_x11modes.c
Expand Up @@ -204,7 +204,7 @@ X11_InitModes(_THIS)
mode.refresh_rate = 0;
mode.driverdata = NULL;

displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata));
if (!displaydata) {
continue;
}
Expand Down Expand Up @@ -272,19 +272,31 @@ CheckXinerama(Display * display, int *major, int *minor)
/* Allow environment override */
env = getenv("SDL_VIDEO_X11_XINERAMA");
if (env && !SDL_atoi(env)) {
#ifdef X11MODES_DEBUG
printf("Xinerama disabled due to environment variable\n");
#endif
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XINERAMA) {
#ifdef X11MODES_DEBUG
printf("Xinerama support not available\n");
#endif
return SDL_FALSE;
}

/* Query the extension version */
if (!XineramaQueryExtension(display, &event_base, &error_base) ||
!XineramaQueryVersion(display, major, minor) ||
!XineramaIsActive(display)) {
#ifdef X11MODES_DEBUG
printf("Xinerama not active on the display\n");
#endif
return SDL_FALSE;
}
#ifdef X11MODES_DEBUG
printf("Xinerama available!\n");
#endif
return SDL_TRUE;
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
Expand All @@ -301,17 +313,29 @@ CheckXRandR(Display * display, int *major, int *minor)
/* Allow environment override */
env = getenv("SDL_VIDEO_X11_XRANDR");
if (env && !SDL_atoi(env)) {
#ifdef X11MODES_DEBUG
printf("XRandR disabled due to environment variable\n");
#endif
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XRANDR) {
#ifdef X11MODES_DEBUG
printf("XRandR support not available\n");
#endif
return SDL_FALSE;
}

/* Query the extension version */
if (!XRRQueryVersion(display, major, minor)) {
#ifdef X11MODES_DEBUG
printf("XRandR not active on the display\n");
#endif
return SDL_FALSE;
}
#ifdef X11MODES_DEBUG
printf("XRandR available!\n");
#endif
return SDL_TRUE;
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
Expand All @@ -328,19 +352,31 @@ CheckVidMode(Display * display, int *major, int *minor)
/* Allow environment override */
env = getenv("SDL_VIDEO_X11_XVIDMODE");
if (env && !SDL_atoi(env)) {
#ifdef X11MODES_DEBUG
printf("XVidMode disabled due to environment variable\n");
#endif
return SDL_FALSE;
}

if (!SDL_X11_HAVE_XVIDMODE) {
#ifdef X11MODES_DEBUG
printf("XVidMode support not available\n");
#endif
return SDL_FALSE;
}

/* Query the extension version */
vm_error = -1;
if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error)
|| !XF86VidModeQueryVersion(display, major, minor)) {
#ifdef X11MODES_DEBUG
printf("XVidMode not active on the display\n");
#endif
return SDL_FALSE;
}
#ifdef X11MODES_DEBUG
printf("XVidMode available!\n");
#endif
return SDL_TRUE;
}

Expand Down Expand Up @@ -437,8 +473,6 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
mode.format = sdl_display->current_mode.format;
mode.driverdata = NULL;

data->use_xrandr = 0;
data->use_vidmode = 0;
screen_w = DisplayWidth(display, data->screen);
screen_h = DisplayHeight(display, data->screen);

Expand Down

0 comments on commit cc4f35c

Please sign in to comment.