SDL_CreateWindow: No available displays

Hi

I tinkered a bit and managed to get steam kind of working in big picture mode
under gdb. It’s not working with SDL_WINDOW_FULLSCREEN so I needed to break
steam at SDL_CreateWindo and change the flags to just SDL_WINDOW_OPENGL which
seemed to work as expected (except for not being properly full screen).

A tiny test app that creates a screen and colors it red is also broken and
working for the same set of flags.

I’d appreciate pointers as to what needs and doesn’t need to be set up for a
SDL_VideoDisplay to work correctly (in particular for full screen). Or perhaps,
which code might care about XRandR output vs screen differences and need to
change for plain screens to work as SDL_VideoDisplays. And as a more distant
question, when should we and when shouldn’t we add screens as SDL_VideoDisplays.----
x11: also create displays based on plain screens

In case SDL is used on an X11 system with no connected displays (xrandr
outputs), SDL_CreateWindow will fail with error:

No available displays

Currently that makes SDL apps largely unusable on chrome remote desktop systems
(and possibly other remote desktops).

This change makes SDL also consider the more virtual “screens” themselves as
potentially usable displays, rather than requiring a physical “output” to be
available and connected.

diff -r 330f500d5815 -r cec47d7a4404 src/video/x11/SDL_x11modes.c
— a/src/video/x11/SDL_x11modes.c Wed Feb 17 15:14:20 2016 +0800
+++ b/src/video/x11/SDL_x11modes.c Wed Mar 02 00:57:27 2016 +0000
@@ -491,6 +491,41 @@
SDL_AddVideoDisplay(&display);
}

  •        // Add the screen itself as a display.
    
  •        if (res->nmode && !looking_for_primary) {
    
  •            SDL_DisplayData *displaydata;
    
  •            char display_name[128];
    
  •            SDL_DisplayMode mode;
    
  •            SDL_VideoDisplay display;
    
  •            displaydata = (SDL_DisplayData *) SDL_calloc(1, sizeof(*displaydata));
    
  •            if (!displaydata) {
    
  •                return SDL_OutOfMemory();
    
  •            }
    
  •            SDL_zero(mode);
    
  •            mode.w = res->modes[0].width;
    
  •            mode.h = res->modes[0].height;
    
  •            mode.format = pixelformat;
    
  •            displaydata->screen = screen;
    
  •            displaydata->visual = vinfo.visual;
    
  •            displaydata->depth = vinfo.depth;
    
  •            displaydata->hdpi = 75;
    
  •            displaydata->vdpi = 75;
    
  •            displaydata->ddpi = 75;
    
  •            displaydata->scanline_pad = scanline_pad;
    
  •            displaydata->use_xrandr = 1;
    
  •            SDL_zero(display);
    
  •            sprintf(display_name, "Screen %d", screen);
    
  •            display.name = display_name;
    
  •            display.desktop_mode = mode;
    
  •            display.current_mode = mode;
    
  •            display.driverdata = displaydata;
    
  •            SDL_AddVideoDisplay(&display);
    
  •        }
    
  •        X11_XRRFreeScreenResources(res);
       }
    
    }