[X11] Obey DISPLAY environment variable when selecting screen (Steaphan Greene)
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 15 Oct 2014 18:33:43 -0300
changeset 91673d2c0f659ad3
parent 9166 e5a2e31d4bee
child 9168 b8e85a5ac99a
[X11] Obey DISPLAY environment variable when selecting screen (Steaphan Greene)

Discussed in bug #2192, tested with Xvfb in dual head configuration.
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Wed Oct 15 15:50:35 2014 -0400
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Wed Oct 15 18:33:43 2014 -0300
     1.3 @@ -375,7 +375,7 @@
     1.4  X11_InitModes(_THIS)
     1.5  {
     1.6      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     1.7 -    int screen, screencount;
     1.8 +    int snum, screen, screencount;
     1.9  #if SDL_VIDEO_DRIVER_X11_XINERAMA
    1.10      int xinerama_major, xinerama_minor;
    1.11      int use_xinerama = 0;
    1.12 @@ -423,7 +423,7 @@
    1.13      }
    1.14  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
    1.15  
    1.16 -    for (screen = 0; screen < screencount; ++screen) {
    1.17 +    for (snum = 0; snum < screencount; ++snum) {
    1.18          XVisualInfo vinfo;
    1.19          SDL_VideoDisplay display;
    1.20          SDL_DisplayData *displaydata;
    1.21 @@ -433,6 +433,15 @@
    1.22          char display_name[128];
    1.23          int i, n;
    1.24  
    1.25 +        /* Re-order screens to always put default screen first */
    1.26 +        if (snum == 0) {
    1.27 +            screen = DefaultScreen(data->display);
    1.28 +        } else if (snum == DefaultScreen(data->display)) {
    1.29 +            screen = 0;
    1.30 +        } else {
    1.31 +            screen = snum;
    1.32 +        }
    1.33 +
    1.34  #if SDL_VIDEO_DRIVER_X11_XINERAMA
    1.35          if (xinerama) {
    1.36              if (get_visualinfo(data->display, 0, &vinfo) < 0) {