intel-virtual-output: Fallback to probing GetScreenResources

If the Display doesn't support the more recent non-forced-detection
GetScreenResources, use the older version instead.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-09-02 22:27:42 +01:00
parent 7c5d269f25
commit e6e6572ac8
1 changed files with 18 additions and 6 deletions

View File

@ -165,6 +165,17 @@ static int xlib_vendor_is_xorg(Display *dpy)
return strstr(vendor, "X.Org") || strstr(vendor, "Xorg");
}
static inline XRRScreenResources *_XRRGetScreenResourcesCurrent(Display *dpy, Window window)
{
XRRScreenResources *res;
res = XRRGetScreenResourcesCurrent(dpy, window);
if (res == NULL)
res = XRRGetScreenResources(dpy, window);
return res;
}
#define XORG_VERSION_ENCODE(major,minor,patch,snap) \
(((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap)
@ -399,7 +410,7 @@ static int clone_update_modes__randr(struct clone *clone)
if (from_info == NULL)
goto err;
to_res = XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
to_res = _XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
if (to_res == NULL)
goto err;
@ -491,7 +502,7 @@ static int clone_update_modes__fixed(struct clone *clone)
assert(clone->src.rr_output);
res = XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
res = _XRRGetScreenResourcesCurrent(clone->src.dpy, clone->src.window);
if (res == NULL)
goto err;
@ -555,7 +566,7 @@ static RROutput claim_virtual(struct display *display, char *output_name, int nc
DBG(("%s(%d)\n", __func__, nclone));
res = XRRGetScreenResourcesCurrent(dpy, display->root);
res = _XRRGetScreenResourcesCurrent(dpy, display->root);
if (res == NULL)
return 0;
@ -789,7 +800,7 @@ static void context_update(struct context *ctx)
DBG(("%s\n", __func__));
res = XRRGetScreenResourcesCurrent(dpy, ctx->display->root);
res = _XRRGetScreenResourcesCurrent(dpy, ctx->display->root);
if (res == NULL)
return;
@ -901,7 +912,7 @@ static void context_update(struct context *ctx)
DBG(("%s fb bounds (%d, %d)x(%d, %d)\n", DisplayString(display->dpy),
x1, y1, x2-x1, y2-y1));
res = XRRGetScreenResourcesCurrent(display->dpy, display->root);
res = _XRRGetScreenResourcesCurrent(display->dpy, display->root);
if (res == NULL)
continue;
@ -1795,10 +1806,11 @@ static int last_display_add_clones__randr(struct context *ctx)
display_init_randr_hpd(display);
res = XRRGetScreenResourcesCurrent(display->dpy, display->root);
res = _XRRGetScreenResourcesCurrent(display->dpy, display->root);
if (res == NULL)
return -ENOMEM;
DBG(("%s - noutputs=%d\n", DisplayString(display->dpy), res->noutput));
for (i = 0; i < res->noutput; i++) {
XRROutputInfo *o = XRRGetOutputInfo(display->dpy, res, res->outputs[i]);
struct clone *clone = add_clone(ctx);