diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-06 14:09:40 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-01-06 14:18:08 +0000 |
commit | 9083d2ed5876f1891727b512da57766d8d11af56 (patch) | |
tree | 08087f63c73d833038f0411f7e4e1fd19aff2e11 | |
parent | 5c735befdcc40f94bd740be9fc0df54ad53aa174 (diff) |
intel-virtual-output: Print more helpful error when run on the wrong server
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tools/virtual.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/virtual.c b/tools/virtual.c index bcbcb425..6b6d9771 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -977,6 +977,35 @@ out: return rr_output; } +static int check_virtual(struct display *display) +{ + XRRScreenResources *res; + int found = -ENOENT; + int i; + + res = _XRRGetScreenResourcesCurrent(display->dpy, display->root); + if (res == NULL) + return -ENOMEM; + + for (i = 0; found == -ENOENT && i < res->noutput; i++) { + XRROutputInfo *output; + + output = XRRGetOutputInfo(display->dpy, res, res->outputs[i]); + if (output == NULL) + continue; + + if (strcmp(output->name, "VIRTUAL0") == 0) + found = 0; + + XRRFreeOutputInfo(output); + } + XRRFreeScreenResources(res); + + DBG(XRR, ("%s(%s): has VIRTUAL0? %d\n", + __func__, DisplayString(display->dpy), found)); + return found; +} + static int stride_for_depth(int width, int depth) { if (depth == 24) @@ -3419,6 +3448,13 @@ int main(int argc, char **argv) goto out; } + ret = check_virtual(ctx.display); + if (ret) { + fprintf(stderr, "No VIRTUAL outputs on \"%s\".\n", + DisplayString(ctx.display->dpy)); + goto out; + } + if (singleton) { XSelectInput(ctx.display->dpy, ctx.display->root, PropertyChangeMask); if (first_display_has_singleton(&ctx)) { |