mirror of https://github.com/encounter/SDL.git
X11: Let XRandR respect multiple screens (DISPLAY=:0.0 vs :0.1, etc).
This commit is contained in:
parent
11f2a9f8c4
commit
5224dfcc9a
|
@ -357,16 +357,12 @@ SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen,
|
|||
int
|
||||
X11_InitModes_XRandR(_THIS)
|
||||
{
|
||||
/* In theory, you _could_ have multiple screens (like DISPLAY=:0.0
|
||||
and DISPLAY=:0.1) but no XRandR system we care about is like this,
|
||||
as all the physical displays would be separate XRandR "outputs" on
|
||||
the one X11 virtual "screen". So we don't use ScreenCount() here. */
|
||||
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
Display *dpy = data->display;
|
||||
const int screencount = ScreenCount(dpy);
|
||||
const int default_screen = DefaultScreen(dpy);
|
||||
RROutput primary = X11_XRRGetOutputPrimary(dpy, RootWindow(dpy, default_screen));
|
||||
Atom EDID = X11_XInternAtom(dpy, "EDID", False);
|
||||
const int screen = DefaultScreen(dpy);
|
||||
RROutput primary;
|
||||
XRRScreenResources *res = NULL;
|
||||
Uint32 pixelformat;
|
||||
XVisualInfo vinfo;
|
||||
|
@ -374,15 +370,24 @@ X11_InitModes_XRandR(_THIS)
|
|||
int looking_for_primary;
|
||||
int scanline_pad;
|
||||
int output;
|
||||
int i, n;
|
||||
int screen, i, n;
|
||||
|
||||
for (looking_for_primary = 1; looking_for_primary >= 0; looking_for_primary--) {
|
||||
for (screen = 0; screen < screencount; screen++) {
|
||||
|
||||
/* we want the primary output first, and then skipped later. */
|
||||
if ((looking_for_primary && (screen != default_screen)) ||
|
||||
(!looking_for_primary && (screen == default_screen))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (get_visualinfo(dpy, screen, &vinfo) < 0) {
|
||||
return -1;
|
||||
continue; /* uh, skip this screen? */
|
||||
}
|
||||
|
||||
pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo);
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) {
|
||||
return SDL_SetError("Palettized video modes are no longer supported");
|
||||
continue; /* Palettized video modes are no longer supported */
|
||||
}
|
||||
|
||||
scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8;
|
||||
|
@ -399,12 +404,9 @@ X11_InitModes_XRandR(_THIS)
|
|||
|
||||
res = X11_XRRGetScreenResources(dpy, RootWindow(dpy, screen));
|
||||
if (!res) {
|
||||
return -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
primary = X11_XRRGetOutputPrimary(dpy, RootWindow(dpy, screen));
|
||||
|
||||
for (looking_for_primary = 1; looking_for_primary >= 0; looking_for_primary--) {
|
||||
for (output = 0; output < res->noutput; output++) {
|
||||
XRROutputInfo *output_info;
|
||||
int display_x, display_y;
|
||||
|
@ -419,8 +421,8 @@ X11_InitModes_XRandR(_THIS)
|
|||
XRRCrtcInfo *crtc;
|
||||
|
||||
/* The primary output _should_ always be sorted first, but just in case... */
|
||||
if ((looking_for_primary && (res->outputs[output] != primary)) ||
|
||||
(!looking_for_primary && (res->outputs[output] == primary))) {
|
||||
if ((looking_for_primary && ((screen != default_screen) || (res->outputs[output] != primary))) ||
|
||||
(!looking_for_primary && (screen == default_screen) && (res->outputs[output] == primary))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -490,6 +492,7 @@ X11_InitModes_XRandR(_THIS)
|
|||
SDL_AddVideoDisplay(&display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
X11_XRRFreeScreenResources(res);
|
||||
|
||||
|
|
Loading…
Reference in New Issue